【问题标题】:Anyway to modify a masterpage control from a contentpage update panel?无论如何要从内容页面更新面板修改母版页控件?
【发布时间】:2014-03-30 08:47:36
【问题描述】:

这是我为 Web 应用程序设计的单源弹出模式。 我在母版页上放置了一个占位符,并将下面的代码放在一个单独的类中。类文件接收消息并构建模态 html。

这适用于完整的回发,但在从 ajax 更新面板中调用时无效。

我知道为什么。我只是不知道有什么办法。有什么想法吗?

 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

【问题讨论】:

    标签: asp.net ajax master-pages


    【解决方案1】:

    好的,这就是我所做的。我添加了一个名为“容器”的可选变量,当在更新面板中调用对话框时可以传递该变量。

    Public Shared Sub showModalMsg(ByVal sMsg As String,
                                  Optional ByVal container As Control = Nothing)
    

    我在这里发布了我的完整解决方案:

    How can I use a single modal across my web application and avoid repetative html on every page?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-14
      • 2013-01-25
      • 1970-01-01
      • 2021-11-29
      相关资源
      最近更新 更多