如何为updatepanel触发器分配转发器中的控制ID [英] how to assign control id which is in repeater for updatepanel triggers

查看:91
本文介绍了如何为updatepanel触发器分配转发器中的控制ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i在转发器内有一个下拉列表。

我有更新面板,

i想要将ddl id分配给更新面板触发器。



但我得到控件ID未找到错误。



可以任何一个PLZ帮助我,我如何将此控制ID分配给更新面板触发器。



i有这个代码,但我'我确定我必须在哪里调用它。

代码

 //创建一个新的异步触发器
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger() ;

//设置将在UpdatePanel上触发回发的控件
trigger.ControlID =lnkbtncommit;

//设置控件的事件名称
trigger.EventName =Click;

//将触发器添加到UpdatePanels的触发器集合
pnlUpdate.Triggers.Add(触发器);





plz帮助我。



谢谢

解决方案

这可能是因为你的触发器ControlID超出触发器集合的范围。还有

您已将 lnkbtncommit 设置为更新面板的控件ID。尝试这样设置,



 trigger.ControlID =  < span class =code-string> DropDownList1; 
trigger.EventName = SelectedIndexChanged;





您也可以在aspx中设置更新面板触发器的下拉列表ID,如下所示



< asp:updatepanel id =   UpdatePanel1 runat =   server >  
< triggers>
< asp:asyncpostbacktrigger controlid = DropDownList1 eventname = SelectedIndexChanged />
< / 触发器 >
< contenttemplate>
..... < / contenttemplate > < / asp:updatepanel >


Hi guys,

i have a dropdownlist inside the repeater.
and i have update panel for it,
i want to assign ddl id to the update panel triggers.

But i'm getting control id not found error.

Can any one plz help me, how can i assign this control id to the update panel triggers.

i have this code, but i'm sure where i have to call this.
CODE

//Creates a new async trigger
    AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();

    //Sets the control that will trigger a post-back on the UpdatePanel
    trigger.ControlID = "lnkbtncommit";

    //Sets the event name of the control
    trigger.EventName = "Click";

    //Adds the trigger to the UpdatePanels' triggers collection
    pnlUpdate.Triggers.Add(trigger);



plz help me.

Thanks

解决方案

It might because of your trigger ControlID is out of scope to Trigger collection.Also
You have set lnkbtncommit as the control ID for the update panel. Try setting it like this,

trigger.ControlID = "DropDownList1";
trigger.EventName = "SelectedIndexChanged";



Also you can set your dropdownlist ID for the update panel trigger like below in aspx

<asp:updatepanel id="UpdatePanel1" runat="server">
<triggers>
<asp:asyncpostbacktrigger controlid="DropDownList1" eventname="SelectedIndexChanged" />
</triggers>
<contenttemplate>
.....</contenttemplate></asp:updatepanel>


这篇关于如何为updatepanel触发器分配转发器中的控制ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆