动态面板的UpdatePanel触发器注册是不可能的! [英] UpdatePanel Trigger registration for dynamic controls is IMPOSSIBLE!

查看:56
本文介绍了动态面板的UpdatePanel触发器注册是不可能的!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

动态创建的ImageButton ...遇到很大的问题...

我的情况如下:

I have a big problem with a dynamically-created ImageButton...

My scenario is as follows:

  1. 我有一个带有ScriptManager控件和一个包含按钮的用户控件的母版页".
  2. 当我单击该按钮时,它会打开一个ModalPopUpExtender(也包含在其中)包含UpdatePanel子项的同一用户控件
  3. 在该UpdatePanel内,有一个包含动态标签和ImageButtons的表!
  4. UpdatePanel设置为有条件的,因此当我单击一个ImageButton,它不会丢失任何表行...
  5. 问题是这些动态控件未注册到scriptmanager或"AsyncPostBackTrigger",因此它们不会触发任何回发! li>
  1. I have a "master page" with a ScriptManager control and a usercontrol containing a button.
  2. When I click the button, it opens a ModalPopUpExtender (also contained in that same usercontrol) that contains an UpdatePanel child
  3. Inside that UpdatePanel, there is a table that contains dynamic labels and ImageButtons!
  4. The UpdatePanel is set to Conditional, so when I click an ImageButton, it doesn''t lose any table rows...
  5. The problem is that these dynamic controls are NOT REGISTERED to scriptmanager or "AsyncPostBackTrigger" so they don''t trigger any postback!



我在表单初始化后尝试注册它们,但失败了:



I tried to register them after the form initialization, but I failed:

  1. 我的ScriptManager在父页面中,我不知道如何调用它来调用RegisterAsyncPostBackControl() ...如何从我的ascx到达父控件?
  2. 如果我理解正确,那么在表单初始化之后,我就不需要在我的更新面板中注册触发器了. ...是真的吗? (我读到我是通过调用RegisterAsyncPostBackControl做到的,是真的吗?)
  1. My ScriptManager is in the parent page and I don''t know how to reach it to call RegisterAsyncPostBackControl()... How can I reach my parent control from my ascx?
  2. If I understand correctly, I don''t need to register Trigger to my Update Panel after the form init... Is this true? (I read that I do it by calling RegisterAsyncPostBackControl, is this true?)



我在声明动态ImageButton之后编写了以下代码:



I wrote this code after the declaration of my dynamic ImageButton:

AsyncPostBackTrigger ImgAddTrigger = new AsyncPostBackTrigger();
ImgAddTrigger.ControlID = ImgAdd.ID + cont.ToString();
ImgAddTrigger.EventName = "Click";
UpdatePanelTabellaPartner.Triggers.Add(ImgAddTrigger);
UpdatePanelTabellaPartner.Update();



...但是,它没有用.因此,我认为我必须调用RegisterAsyncPostBackControl.

预先感谢您的回答!
如果有人可以解决这个问题,我认为那是最好的!我快要解决这个问题了!



...But, it didn''t work. So I think that I must call RegisterAsyncPostBackControl.

Thanks in advance for the answers!
If anybody can solve this problem, I think that is the best! I''m going crazy trying to solve this problem!

推荐答案

好.以下几件事对您有帮助:

Okay. Here are few things that should help you:

enricosoft写道:
enricosoft wrote:

AsyncPostBackTrigger ImgAddTrigger = new AsyncPostBackTrigger();

AsyncPostBackTrigger ImgAddTrigger = new AsyncPostBackTrigger();


不支持以编程方式添加AsyncPostBackTrigger控件.若要以编程方式注册回发控件,请使用ScriptManager控件的RegisterAsyncPostBackControl方法.然后,当控件回发时,调用UpdatePanel控件的Update方法.有关详细信息:引用 [


Programmatically adding AsyncPostBackTrigger controls is not supported. To programmatically register a postback control, use the RegisterAsyncPostBackControl method of the ScriptManager control. Then call the Update method of the UpdatePanel control when the control posts back. For details:Refer[^].

enricosoft写道:
enricosoft wrote:

我的ScriptManager在父页面中,我不知道如何到达它

My ScriptManager is in the parent page and I don''t know how to reach it


ScriptManager currPageScriptManager = ScriptManager.GetCurrent(Page) as ScriptManager;
if (currPageScriptManager != null)
{
 // write your code
 // currPageScriptManager.RegisterAsyncPostBackControl(myControlName);
 // Now call the UpdatePanel.Update() when myControlName posts back.
}


有关详细信息:
引用 [


For details: Refer[^]

:thumbsup:


嗨!
感谢您的回答...在这种情况下,我可以访问位于父页面中的ScriptManager并注册AsyncPostBackControl,最后,当我单击动态图像按钮"时,更新UpdatePanel BUT,不起作用! (使用调试模式,与我的imageButton关联的动态事件未运行)... :(

有什么想法吗?
非常感谢!
Hi!
Thanks for the answer... In this case i can reach the ScriptManager situated in my Parent Page and register the AsyncPostBackControl and at the end i Update my UpdatePanel BUT when i click my Dynamic ImageButton,don''t work! (using debug mode,the dynamic event associated to my imageButton not run)... :(

Any ideas?
Thanks a lot!


嗨!,
我尝试应用我建议的更改,但没有起作用(事件未关联动态部分)... TI一段时间,我从母版页解释了这种情况,我单击了一个运行查询的按钮,并根据该按钮我在UpdatePanel中包含的asptable中创建动态控件,然后看到显示我的asptable的ModalPopUpExtender ...我已经尝试了所有方法,现在我非常绝望)

我做过的测试是:
A)UpdatePanel.Updatemode =总是--->似乎要进行回发(尽管实际上是使用Visual Studio进行调试的,但他没有进入其关联功能),但是所有动态控件都消失了,无法使用!


B)UpdatePanel.UpdateMode =条件--->在此保持动态控件.在我的父页面中,还为ScriptManager中的每个动态控件记录了可单击的"RegisterAsyncPostBackControl",它不会回发! (这仅是因为无法记录表单初始化之后的"AsyncPostBackTrigger").使他们执行PostBack总记录"RegisterPostBackControl"的唯一方法,但是即使如此,我还是关闭了ModalPopUpExtender.即使具有AutoPostBack = true的ListBox控件也不是!然后,我尝试使用UpdateMode = always在另一个UpdatePanel内创建动态控件,但我意识到这种方法不一样!因此,不仅对我来说是"UpdateMode"的问题!

1)问题可能是由于我的ModalPopupExtender在不同的更新面板和动态控件中创建的?

2)不要以为创建动态控件,在ScriptManager上关联并记录一个事件会出错

3)我们确定有一种方法可以在Form_init之后创建运行动态控件的方法吗?我知道ScriptManager是"RegisterAsyncPostBackControl",但其他人不是...如果在form_init和form_load之后声明,"AsyncPostBackTrigger"可以很好地工作吗?
Hi!,
I tried to apply the change I suggested, but does not work the same (the event not associated dynamic part) ... TI for a while I explain the situation from my master page I click a button that runs a query and according to that I create my dynamic controls in a asptable contained in an UpdatePanel, and then I see my ModalPopUpExtender that shows me my asptable ... I''ve tried everything and now I am quite desperate)

The tests I''ve done are:
A) UpdatePanel.Updatemode = always ---> seem to make postback (though actually debugging using visual studio, he does not enter into its associated function), but all dynamic controls disappear and can not be used!


B) UpdatePanel.UpdateMode = conditional ---> Here dynamic controls are maintained. Also recorded "RegisterAsyncPostBackControl" clickable for each dynamic control in ScriptManager in my parent page, it does not postback! (This only because the "AsyncPostBackTrigger" after the form init can not be recorded). The only way to make them do PostBack total record "RegisterPostBackControl" but even so I closed my ModalPopUpExtender. Even as the ListBox control that has AutoPostBack = true does not it! I then tried to create my dynamic control inside another UpdatePanel with UpdateMode = always and I realized that does not work the same! So not only is a problem of ''UpdateMode to me!

1) the problem can be caused by my ModalPopupExtender are created where the different update panel and dynamic controls?

2) Do not think of making a mistake to create my dynamic controls, associate and record an event on the ScriptManager

3) we are sure that there is a way to run the dynamic controls are created after the Form_init? I knew "RegisterAsyncPostBackControl" the ScriptManager but not others ...can "AsyncPostBackTrigger" works well if declared after form_init and form_load?


这篇关于动态面板的UpdatePanel触发器注册是不可能的!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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