动态添加的链接按钮单击不会触发(仅初始化??),更新面板和触发器
当用户选择“帐户”时,我们动态创建一个包含所选日期的链接按钮。
但是,单击按钮时不会触发 linkbutton onclick 处理程序。
谢谢
Dim linkBtn As New LinkButton
linkBtn.Text = "blah"
AddHandler linkBtn.Click, AddressOf linkButtonHandler
linkBtn.ID = panelDatesRencontre.Controls.OfType(Of LinkButton).Count
panelDatesRencontre.Controls.Add(linkBtn)
ScriptManager1.RegisterAsyncPostBackControl(linkBtn)
Dim Trigger1 As New AsyncPostBackTrigger
Trigger1.ControlID = linkBtn.ID
Trigger1.EventName = "Click"
UpdatePanel2.Triggers.Add(Trigger1)
回答:我在 page_load 中做到了,它似乎有效
When the user selects an "account" we dynamically create a linkbutton with the selected dates.
However, the linkbutton onclick handler doesn't fire when the button is clicked.
thx
Dim linkBtn As New LinkButton
linkBtn.Text = "blah"
AddHandler linkBtn.Click, AddressOf linkButtonHandler
linkBtn.ID = panelDatesRencontre.Controls.OfType(Of LinkButton).Count
panelDatesRencontre.Controls.Add(linkBtn)
ScriptManager1.RegisterAsyncPostBackControl(linkBtn)
Dim Trigger1 As New AsyncPostBackTrigger
Trigger1.ControlID = linkBtn.ID
Trigger1.EventName = "Click"
UpdatePanel2.Triggers.Add(Trigger1)
Answer: i make that in page_load, it seems to work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使处理程序可用,必须在 page_init 部分中重新创建它。
否则,您只会得到回发,而不会执行处理程序。
In order for the handler to be available it has to be recreated in the page_init section.
Otherwise you'll just get a postback without the handler executing.