如何为updatepanel触发器获取转发器的按钮ID [英] how to get repeater's button id for updatepanel triggers
本文介绍了如何为updatepanel触发器获取转发器的按钮ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
i在带有更新面板的转发器中有一个按钮。
现在,问题是,触发器controlID无法在转发器中获取按钮ID,
如何获取此按钮ID。
plz建议我,
Hi guys,
i have a button in a repeater with update panel.
now, the problem is, the triggers controlID is not able get button id which in the repeater,
how to get this button id.
plz suggest me,
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table class="table table-bordered table-hover">
<thead class="bg-primary lt">
<tr>
<th style="width: 50px;">
S.No.
</th>
<th>
Name
</th>
<th>
Position
</th>
<th>
Extension
</th>
<th>
Action
</th>
</tr>
</thead><tbody>
</HeaderTemplate>
<itemtemplate>
<tr>
<td><b>
<%# Container.ItemIndex + 1 %></b>
</td>
<td><%# Eval("EmpName") %></td>
<td><%# Eval("Position") %></td>
<td><%# Eval("ExtensionNo") %></td>
<td>
<asp:LinkButton ID="btndel1" CssClass="btn btn-danger" runat="server" CommandName="delete"
CommandArgument='<%# Eval("RecID") %>' ToolTip='Delete'
OnClientClick="return confirm('Are you SURE you want to Delete this Ext?');"
OnClick="btndel_Click">
<span class="fa fa-trash-o"></span></asp:LinkButton>
 
<asp:LinkButton ID="btnedit1" CssClass="btn btn-info" runat="server" ToolTip="Edit"
CommandArgument='<%# Eval("RecID") %>' OnClick="btnedit_Click" >
<i class="fa fa-edit"></i></asp:LinkButton>
</td>
</tr>
</itemtemplate>
<Footertemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btndel1" /> //throwing error id not found
<asp:AsyncPostBackTrigger ControlID="btnedit1" /> // same error
</Triggers>
</asp:UpdatePanel>
谢谢
thanks
推荐答案
你是一个幸运的人 - 我刚刚写了一篇文章,解释了控件ID如何在ASP.NET模板中运行...
了解ASP.NET模板 [ ^ ]
想想看它 - 你有几个按钮,据说有相同的ID - sot你想绑定触发器到哪个控件?
如果您阅读MSDN关于 AsyncPostBackTrigger [ ^ ] - 你可以看到你必须提供一个标识单个控件的特定ID!
可能你唯一的(也是最好的)选择是来自代码隐藏 - http://msdn.microsoft.com/ en-us / library / system.web.ui.scriptmanager.registerasyncpostbackcontrol.aspx [ ^ ]
You are a fortunate man - I just wrote an article that explains how Control ID works in ASP.NET templates...
Understanding ASP.NET Templates[^]
Think about it - you have several buttons, that supposedly have the same ID - sot to which control do you want to bind the trigger?
If you read MSDN about AsyncPostBackTrigger[^] - you can see that you have to provide a specific ID, that identifies a single control!
Probably your only (and best) option is to do it from the code-behind - http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerasyncpostbackcontrol.aspx[^]
这篇关于如何为updatepanel触发器获取转发器的按钮ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文