无论如何修改从contentpage更新面板一个母版控制? [英] Anyway to modify a masterpage control from a contentpage update panel?
问题描述
下面是我想出了一个Web应用程序的单一源弹出模式。
我把一个占位符母版页及以下在一个单独的类code上。类文件接收消息并构建HTML模式。
这适用于完全回发,而不是从一个Ajax更新面板中调用时。
我知道为什么。我只是不知道它周围的任何方式。任何想法?
公共类普通
继承SITEMASTER 公共共享子showModalMsg(BYVAL sMsg的作为字符串) 昏暗的LBL作为新标签
lbl.Text = sMsg的
(为简单起见,省略了div的建筑物,使模态)
昏暗页面处理器= HttpContext.Current.CurrentHandler
如果TypeOf运算页面处理器是System.Web.UI.Page然后
昏暗的pH值占位符= DirectCast(页面处理器,System.Web.UI.Page).Master.FindControl(phModalDialog)
如果pH值状态并没有任何再
ph.Controls.Add(LBL)
万一
万一 末级
好吧,这里是我做的。我添加了一个名为容器可选变量,可以调用一个更新面板内的对话框时传递。
公共共享子showModalMsg(BYVAL sMsg的作为字符串,
可选BYVAL容器作为控制=无)
我在这里张贴了我完整的解决方案:
<一个href=\"http://stackoverflow.com/questions/22772757/how-can-i-use-a-single-modal-across-my-web-application-and-avoid-repetative-html/22772774#22772774\">How我可以用一个单一的模式在我的web应用程序,并避免在每一页上但却难免重复HTML?
Here is what I came up with for a single-source popup modal for a web application. I put a placeholder on the master page and the code below in a separate class. The class file receives the message and builds the modal html.
This works on full postback, but not when called from within an ajax update panel.
I know why. I just don’t know of any way around it. Any ideas?
Public Class Common
Inherits SiteMaster
Public Shared Sub showModalMsg(ByVal sMsg As String)
Dim lbl As New Label
lbl.Text = sMsg
'(for simplicity, the building of the div to make the modal is omitted)
Dim pageHandler = HttpContext.Current.CurrentHandler
If TypeOf pageHandler Is System.Web.UI.Page Then
Dim ph As PlaceHolder = DirectCast(pageHandler, System.Web.UI.Page).Master.FindControl("phModalDialog")
If ph IsNot Nothing Then
ph.Controls.Add(lbl)
End If
End If
End Class
Ok, here is what I did. I added an optional variable called 'container' that can be passed when calling the dialog within an update panel.
Public Shared Sub showModalMsg(ByVal sMsg As String,
Optional ByVal container As Control = Nothing)
I posted my full solution here:
How can I use a single modal across my web application and avoid repetative html on every page?
这篇关于无论如何修改从contentpage更新面板一个母版控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!