How to pass the StoryID to a Javascript file everytime the Usercontrol loads!

Oct 20, 2009 at 4:05 AM

Hi,

I am creating the Star Rating and adding it to the Kigg. I am getting help from nacid big time.

I got stuck on the process of loading the Rating User control everytime the Story loads and my Rating needs to differentiate the different Ratings in the mutliple listings of the Stories on the page.

So, I need to give the Story ID everytime Rating User Control Loads and load the Javascript with it with the new StoryID so that, I can concenate the id to the Div Id's.

 

Like So,

<div class="rated">
  <div style="float:left">
    <form id="Form1" method="post" action="">
      <input class="star {split:4}" type="radio" value="01" name="rating" <%= Check(0,0.25,   Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="02" name="rating" <%= Check(0.25,0.5, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="03" name="rating" <%= Check(0.5,0.75, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="04" name="rating" <%= Check(0.75,1,   Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="05" name="rating" <%= Check(1,1.25,   Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="06" name="rating" <%= Check(1.25,1.5, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="07" name="rating" <%= Check(1.5,1.75, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="08" name="rating" <%= Check(1.75,2,   Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="09" name="rating" <%= Check(2,2.25,   Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="10" name="rating" <%= Check(2.25,2.5, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="11" name="rating" <%= Check(2.5,2.75, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="12" name="rating" <%= Check(2.75,3,   Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="13" name="rating" <%= Check(3,3.25,   Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="14" name="rating" <%= Check(3.25,3.5, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="15" name="rating" <%= Check(3.5,3.75, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="16" name="rating" <%= Check(3.75,4,   Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="17" name="rating" <%= Check(4,4.25,   Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="18" name="rating" <%= Check(4.25,4.5, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="19" name="rating" <%= Check(4.5,4.75, Model.AverageRating) %>/>
      <input class="star {split:4}" type="radio" value="20" name="rating" <%= Check(4.75,5,   Model.AverageRating) %>/>
      </form>
  </div>

    <p class="currentlyrated" style="float:left;padding-left:20px;">
        <%= Model.AverageRating > 0 ? "Currently rated " + Model.AverageRating.ToString("f") + " by " + Model.TotalRaters + " people" : "<span style=\"color:red\">Not yet rated.  Be the first to rate this article!</span>"%>
    </p>
  </div>
  <% string storyID = Model.Id.ToString(); %>  
  <div style="clear:both"></div>
  
  <div class="rater">
    <div style="float:left;">
      <form id="rate" method="post" action="">
          <input class="auto-submit-star" type="radio" name="score" value="1"/>
          <input class="auto-submit-star" type="radio" name="score" value="2"/>
          <input class="auto-submit-star" type="radio" name="score" value="3"/>
          <input class="auto-submit-star" type="radio" name="score" value="4"/>
          <input class="auto-submit-star" type="radio" name="score" value="5"/>
          <input type="hidden" name="StoryID" value="<%= Model.Id.ToString() %>" />
      </form>
    </div>
    </div>
    <p style="float:left;padding-left:20px;">
      Rate Now!
    </p>

  <div style="clear:both"></div>

 We all know that one unique id per page on div tags. So, I need to add the storyid to

example:

<div id="rated<%=Model.Id%>">
.....

but at the same time, the unique StoryId should pass on to the javascript as well.

 

So, if anyone knows, please help.

 

Thank you,