[英]Adding Non-Standard Attribute to asp:LinkButton inside Repeater prevents the run of OnItemCommand
I am integrating a Foundation 5 Reveal Modal component with an <asp:LinkButton>
. 我正在将Foundation 5 Reveal Modal组件与<asp:LinkButton>
集成在一起。 For the reveal modal to work it requires the addition of a non-standard HTML attribute data-reveal-id
to the <asp:LinkButton>
. 为了使显示模式起作用,它需要在<asp:LinkButton>
添加一个非标准的HTML属性data-reveal-id
。 If I do 'not' add this attribute in the .aspx
below, then clicking the LinkButton will trigger rptNotice_ItemCommand
. 如果我不“在”下面的.aspx
中添加此属性,则单击LinkButton将触发rptNotice_ItemCommand
。 However, when data-reveal-id
is added to the LinkButton as shown below rptNotice_ItemCommand
does not run, and lbMessage
is not updated. 但是,将data-reveal-id
如下所示添加到LinkButton时, rptNotice_ItemCommand
无法运行,并且lbMessage
也不会更新。 The lbMessage
is required by the database upon submission of the modal form. 提交模态表单后,数据库需要lbMessage
。
How do I get this to work? 我该如何工作?
Is there another way to keep track of the message ID? 还有另一种跟踪消息ID的方法吗?
In the .aspx
file 在.aspx
文件中
<!-- Foundation 5 Reveal Modal -->
<div id="replyModal" class="reveal-modal" data-reveal>
<h2>Reply to Notice</h2>
<asp:Label ID="lbMessage" runat="server" />
<asp:TextBox ID='tbFollowQuestion' runat="server" TextMode="MultiLine" Width="100%" /><br />
<asp:Button ID="btnFollowCancel" runat="server" Text="Cancel" OnClick="followQuestionCancel_Clicked" />
<asp:Button ID="btnFollowQuestion" runat="server" Text="Submit" OnClick="followQuestionSave_Clicked" />
<a class="close-reveal-modal">×</a>
</div>
<asp:Repeater ID="rptNotice" runat="server" OnItemCommand="rptNotice_ItemCommand">
<ItemTemplate>
<div class="row padding-bottom-10 border-bottom-1 margin-bottom-10">
<!-- LinkButton -->
<div class="small-6 medium-2 xlarge-1 columns">
<asp:LinkButton data-reveal-id="replyModal" CommandName="Contact" CommandArgument='<%#Eval("MessageId")%>' ToolTip="Reply" runat="server"><img src="/images/icon/envelop.jpg" alt="Contact Us"><strong class="font-size-14">Reply</strong></asp:LinkButton>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
In the .aspx.cs
file 在.aspx.cs
文件中
public void rptNotice_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
lbMessage.Text = "MessageId: " + e.CommandArgument.ToObjectString();
}
There seems to be possible parsing issue due to unknown parameter. 由于参数未知,似乎存在解析问题。 I would suggest using CommandArgument field. 我建议使用CommandArgument字段。 Try "replyModal" to CommandArgument . 尝试对CommandArgument进行“ replyModal”。
Split the value at backend and get operation type. 在后端拆分值并获取操作类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.