我有关于更新面板和triger与之相关的问题 [英] i have question about update panel and triger asociated with it
问题描述
我有关于更新面板和triger的问题。
我在更新面板中有转发器控件,在更新面板外面有一个用户控件(有按钮)。现在我想要当我点击用户控制的按钮时,我的转发器正在刷新。我怎样才能做到这一点?以下是我的代码
Hi, i have question about update panel and triger asociated with it.
I have repeater control in update panel and one user control(having button) out side the update panel. now i want when i click on button which is in user control, my repeater is being is refreshed. how can i do this? follwing is my code
//user control
<uc1:myUserContrl ID="usercontrol" runat="server"/>
//update panel and repeater control
<asp:updatepanel ID="updReater" runat="server">
<contenttemplate>
here is my repeater control
</contenttemplate>
</asp:updatepanel>
推荐答案
假设您的页面上有ID为ScriptManager1的scriptmanager,请在Page Load事件中编写以下代码:
Suppose you have scriptmanager with ID "ScriptManager1" on your page, write the following code in Page Load event:
ScriptManager1.RegisterAsyncPostBackControl(usercontrol1.FindControl("Button1"));//Button1 is the ID of button inside your user control.
此外,您应该将更新面板的UpdateMode属性设置为Conditional。
Also, you should set "UpdateMode" property of the update panel to "Conditional".
那么,您可以使用触发器为您的更新面板&做有需要。
我只是在下面添加触发代码:
Well, you can use a Trigger for your Update Panel & do the Needful.
I''m just adding the Code for Trigger below:
<asp:updatepanel id="updReater" runat="server">
<contenttemplate>
Here is your repeater control
</contenttemplate>
<triggers>
<asp:asyncpostbacktrigger controlid="Button1" eventname="Click" />
</triggers>
</asp:updatepanel>
在上面的代码行中我是将您的按钮ID视为Button1&针对异步回发定位''点击''事件。
所以只需添加以下几行Code&你的工作将完成。
In the above lines of code I''m considering your Button Id as ''Button1'' & Targeting it''s ''Click'' event for Async Postback.
So Just add these few lines of Code & your job will be done.
这篇关于我有关于更新面板和triger与之相关的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!