jeez, it's not THAT inter-include-connected :)
look in Repository.ascx.vb at the listObject_ItemCommand() function.. you'll see the case statement that processes the rating
Case "PostRating"
Dim objRatingsPanel As Panel
objRatingsPanel = CType(e.Item.Cells(0).FindControl("pnlRatings"), Panel)
Dim objRating As RadioButtonList
objRating = CType(objratingspanel.FindControl("rbRating"), RadioButtonList)
If objRating.SelectedIndex <> -1 Then
repository.UpdateRepositoryRating(objRepository.ItemId, objRating.SelectedValue)
End If
...
|
The highlighted line is the one that is storing the user's vote... so if you want to write a cookie, that would be the place...
I would suggest including the Repository Item's ItemId in the cookie name so you know which item in which repository module they are voting for. Add the code highlighted in green.
If objRating.SelectedIndex <> -1 Then
repository.UpdateRepositoryRating(objRepository.ItemId, objRating.SelectedValue)
Dim cookie As HttpCookie = New HttpCookie("Rated" & objRepository.ItemId.ToString())
cookie.Expires = "1/1/2999"
cookie("Rating") = objRating.SelectedValue.ToString()
Response.Cookies.Add(cookie)
End If
|
Then, the last thing would be to restrict the user from voting again if they're already voted... In the same file, in the same function, you'll see the case statement for displaying the voting controls
Case "ShowRating"
If b_CanRate Then
Dim objRatingsPanel As Panel
objRatingsPanel = CType(e.Item.Cells(0).FindControl("pnlRatings"), Panel)
... |
When the user clicks on the ratings image, it checks the user's security roles to see if they are allowed to rate the iitem ( b_CanRate ), if so, then it displays the voting panel. All you need to do is also add a check for the cookie to make sure it doesn't exist. that way
Case "ShowRating"
If Not Request.Cookies("Rated" & objRepository.ItemId.ToString()) Is Nothing Then
b_CanRate = False
End If
If b_CanRate Then
Dim objRatingsPanel As Panel
objRatingsPanel = CType(e.Item.Cells(0).FindControl("pnlRatings"), Panel)
...
|
So, we first check to see if we have a cookie for this item, if it exists, just force b_CanRate to false and the user will not be able to vote again for that particular item.
Let me know if you have any questions or problems implementing this for your client.