InnerHtml Popup With Masterpage

时间:2014-10-16 14:23:42

标签: javascript jquery html css asp.net

旺旺:

我想在.Net(以及与.Net交互的任何代码)中使用Masterpage进行弹出式构建

注意:

我的代码在IE7以上没有母版页的情况下运行(之前没有测试)和Chrome

问题:

当我尝试将代码添加到母版页时,“Div”显示在页面上而不是弹出窗口。

以下代码是无主页版本。我已经尝试将Div放在母版页和子页面中,但结果相同。

代码:

Aspx Page

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>


    <link rel="stylesheet" type="text/css" media="all" href="css/Annunciator.css" />
</head>
<body>
    <form id="form1" runat="server">


    <asp:Button ID="btnPopUp" runat="server" Text="Show Image and Pop Up " />

           <br />
    <br />
    Test test<div id="AnnunciatorContainer" runat="server"></div>


    </form>
</body>
</html>

.aspx.vb

Partial Class _Default
    Inherits System.Web.UI.Page

    Public Sub ShowAnnouncement(ByVal title As String, ByVal message As String, Optional ByVal image As String = "")

        'Need to have Announcements as a variable 
        'Need to show a photo as well

        title = Trim(title.Replace("<p>", "").Replace("</p>", "").Replace("&nbsp;", " "))
        message = Trim(message.Replace("<p>", "").Replace("</p>", "").Replace("&nbsp;", " "))
        image = Trim(image.Replace("<p>", "").Replace("</p>", "").Replace("&nbsp;", " "))

        If image <> "" Then image = "<img src=""" & image & """ class=""Image"" />"

        Dim data As String = "<div id=""Annunciator""><div class=""Box""><h1>" & title & "</h1><div class=""Content""><p>" & image & message.Replace(Environment.NewLine, "</p><p>") & "</p></div><a href=""?"" title=""Please Continue, I confirm that I have read this announcement"">Click To Close</a></div></div>"

        AnnunciatorContainer.InnerHtml = data

    End Sub

    Protected Sub btnPopUp_Click(sender As Object, e As System.EventArgs) Handles btnPopUp.Click

        Dim vSubjectTitle As String = "Top Title"
        Dim vMainText As String = "Test message"
        Dim vImageURL As String = "Img/Show/Dock.jpg"

        ShowAnnouncement(vSubjectTitle, vMainText, vImageURL) ' show it

    End Sub

End Class

0 个答案:

没有答案
相关问题