我有一个评论主题/讨论板很像这个。整个注释线程是通过函数调用生成的,函数调用返回HTML以显示在页面上。在每个不同评论的底部我都有按钮'有用 - 是/否'并且'标记为不合适的'。当用户点击“是”','否'或者'标记为不合适的'我更新了数据库等,但我也想删除该评论的按钮,并显示“感谢您的反馈和”#39;信息。
我已为每个"反馈按钮组动态命名容器"到目前为止我所做的是使用ID进行javascript回发,以便我能够识别哪个按钮被推送并更新了数据库等。
我挣扎的地方就是找到包含框并更新它的属性以隐藏它并显示另一个提供用户反馈的属性。
所以,.aspx页面
<div id="ThreadIntro" runat="server" class="Box PageSection">
<h3>Query</h3>
<div class="BoxInner">
<asp:Label ID="lblQueryIntro" runat="server" EnableTheming="false"/>
<asp:HiddenField runat="server" ID="hideQueryID" />
<hr />
<asp:Label ID="lblCommentsThread" runat="server" EnableTheming="false"/>
</div>
</div>
要呈现评论主题,请调用代码
lblCommentsThread.Text = thisComments.GetQueryCommentsThreadAsHTMLWidget(strQueryID)
返回此信息(只是&#34;反馈按钮组&#34;)
"<div class=""BoxInner"">" & _
"<div id=""divFeedbackRID" & rdrSQL2("QueryResponseID") & """ runat=""server"">" & _
"<table style=""width:100%;"">" & _
"<tr>" & _
"<td>" & _
"Useful? <input id=""btnUsefulYesRID" & rdrSQL2("QueryResponseID") & """ type=""button"" value=""Yes"" rel=""nofollow"" onclick=""javascript:__doPostBack('UsefulYesRID" & rdrSQL2("QueryResponseID") & "', 'Click_DivButton')""/> <input id=""btnUsefulNoRID" & rdrSQL2("QueryResponseID") & """ type=""button"" value=""No"" rel=""nofollow"" onclick=""javascript:__doPostBack('UsefulNoRID" & rdrSQL2("QueryResponseID") & "', 'Click_DivButton')""/>" & _
"</td>" & _
"<td style=""text-align:right"">" & _
"<a id=""linkInappropriateRID" & rdrSQL2("QueryResponseID") & """ name=""linkInappropriateRID" & rdrSQL2("QueryResponseID") & """ rel=""nofollow"" href=""javascript:__doPostBack('InappropriateRID" & rdrSQL2("QueryResponseID") & "','Click_DivButton')"">Report as inappropriate</a>" & _
"</td>" & _
"</tr>" & _
"</table>" & _
"</div>" & _
"<div id=""divFeedbackThanksRID" & rdrSQL2("QueryResponseID") & """ runat=""server"" style=""display:none;"">" & _
"Thanks for the feedback" & _
"</div>" & _
"</div>" & _
所以,当我点击任一按钮或“不合适”时,链接,这发生了, 代码背后
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Request.Form("__EVENTARGUMENT") = Nothing Then
If Request.Form("__EVENTARGUMENT") = "Click_DivButton" Then
ProcessButtonPush(Request.Form("__EVENTTARGET"), New EventArgs())
End If
End If
End Sub
我需要这样的东西来解决我的问题。我遇到的问题是我无法在第一时间找到div。
Protected Sub ProcessButtonPush(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strQueryID As String = hideQueryID.Value
Dim strResponseID As String
If Left(sender.ToString, 12) = "UsefulYesRID" Then
strResponseID = Mid(sender.ToString, 13)
'Mark this comment as useful etc etc (no worries here, I don't need help for that)
'Find "divFeedbackRID & strResponseID", update attributes to hide
'Find "divFeedbackThanksRID & strResponseID", update attributes to show
Dim divFeedback As HtmlGenericControl = Page.FindControl("divFeedbackRID" & strResponseID)
Dim divFeedbackThanks As HtmlGenericControl = FindControl("divFeedbackThanksRID" & strResponseID)
If Not divFeedback Is Nothing Then
divFeedback.Attributes.Add("style", "display:none;")
divFeedbackThanks.Attributes.Remove("style")
End If
ElseIf Left(sender.ToString, 9) = "UsefulNoRID" Then
'etc
ElseIf Left(sender.ToString, 8) = "InappropriateRID" Then
'etc
End If
End Sub
如果div标签直接放在aspx页面上会很容易,我可以简单地说
divFeedbackThanksRID1.Attributes.Remove("style")
但由于所有div都是从函数调用放在页面上的,所以我无法做到。任何帮助将非常感激。
由于