Hi
I am trying to use a check box within a repeater in an asp.net vb application. Basically, i am have an application that allows users to create blog posts and then other users can comment on them. I am using a check box to provide the user with functionality to like the posts comments.
When the user clicks on like, it is supposed to fire the event which will insert or update the users like record. However, this even does not seem to be firing.
i set up the check box within a table within the repeater as follows:
and here is the check changed event:Code:<td class = "LikeCellRepeat"> Like: <asp:CheckBox ID="chkLikeComment" runat="server" ToolTip="Like" AutoPostBack="True" OnCheckedChanged="chkLikeComment_CheckedChanged"/> <asp:ToggleButtonExtender ID="Toggle_chkLikeComment" runat="server" Enabled="True" TargetControlID="chkLikeComment" CheckedImageAlternateText="Liked" CheckedImageUrl="~/Images/Liked.png" UncheckedImageUrl="~/Images/Unselected.png" ImageHeight="19" ImageWidth="19"> </asp:ToggleButtonExtender> </td>
i included a Msgbox in the event to see if i would at least get that and then the problem might be something else, but i don't even get the msgbox to pop up which is why i'm thinking the check changed event is not even firing.Code:Protected Sub chkLikeComment_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox("like clicked") Dim CommentItem As RepeaterItem = sender.NamingContainer Dim HiddenID As HiddenField = CType(CommentItem.FindControl("HiddenCommentID"), HiddenField) Dim CommentID As Integer = Convert.ToInt32(HiddenID.Value) Dim isCommentLiked As Boolean = ExistingCommentLike(CommentID) Dim isCommentDisliked As Boolean = ExistingCommentDislike(CommentID) If (isCommentLiked = False And isCommentDisliked = False) Then 'user did not previously like or dislike comment, so insert record' AddUserCommentLike(DirectCast(sender, CheckBox).Checked, CommentID) Else 'user previously liked or disliked comment, so update record' UpdateUserCommentLike(DirectCast(sender, CheckBox).Checked, CommentID) End If 'Display how many likes and dislikes there are on this comment' DisplayCommentLikesAndDislikes() End Sub
I've been searching the net for solutions on how to get it to fire, but what i've found so far either does not work or i am not using it properly. I saw something about re-subscribing to the event in repeater's on item data bound, and tried to set up that the way they had, but i am not sure if i did it right, as i get an error that says the checkedchanged cannot be called directly and to use raise event instead...
I have been trying to get this to work for about a week now with no luck. Would appreciate any help i can get...Code:Protected Sub rptComments_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptComments.ItemDataBound Dim CheckLike As CheckBox = CType(e.Item.FindControl("chkLikeComment"), CheckBox) CheckLike.AutoPostBack = True CheckLike.CheckedChanged += New EventHandler(chkLikeComment_CheckedChanged) End Sub
Thanks!


Reply With Quote


