开发者

ModalPopup not working in the Content Page of the Master Page

开发者 https://www.devze.com 2023-02-28 06:02 出处:网络
This is my Content Page <%@ Page Title=\"\" Language=\"C#\" MasterPageFile=\"~/MasterPage.master\" AutoEventWireup=\"true\"

This is my Content Page

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link type="text/css" rel="Stylesheet" href="StyleSheet.css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="script1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel ID="pnl1" runat="server" Height="200" Width="200" CssClass="modalPopup">
                <h1>
                    Hello World
                </h1>
            </asp:Panel>
            <asp:Button ID="btnShow" runat="server" Text="Show" />
            <cc1:ModalPopupExtender ID="mpEditComment" runat="server" PopupControlID="pnl1" TargetControlID="btnShow"
                BackgroundCssClass="modalBackground">
            </cc1:ModalP开发者_Go百科opupExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

This is My Master Page

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!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>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    </asp:ContentPlaceHolder>
    </form>
</body>
</html>


Generally you should put the ScriptManager in your Master page. Then place a ScriptManagerProxy or ToolkitManagerProxy in your aspx page. Also if you are working with .Net 4.0 then you might want to specify AjaxFrameworkMode="Enabled"

You shouldn't need an UpdatePanel for this hello world test.

MasterPage.master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!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 id="Head1" runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" AjaxFrameworkMode="Enabled" runat="server"></asp:ScriptManager>
    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    </asp:ContentPlaceHolder>
    </form>
</body>
</html>

Default.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:content id="Content1" contentplaceholderid="head" runat="Server">
    <link type="text/css" rel="Stylesheet" href="StyleSheet.css" />
</asp:content>
<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1"runat="server"></asp:ScriptManagerProxy>

    <asp:Panel ID="pnl1" runat="server" Height="200" Width="200" CssClass="modalPopup">
        <h1>
            Hello World
        </h1>
        <asp:Button runat="server" Text="ButtonOk"></asp:Button>
        <asp:Button runat="server" Text="ButtonCancel"></asp:Button>
    </asp:Panel>

    <asp:Button ID="btnShow" runat="server" Text="Show" />

    <cc1:ModalPopupExtender ID="mpEditComment" 
        PopupControlID="pnl1" 
        TargetControlID="btnShow"
        OkControlID="ButtonOk"
        CancelControlID="ButtonCancel"
        BackgroundCssClass="modalBackground"
        runat="server"  />

</asp:content>
0

精彩评论

暂无评论...
验证码 换一张
取 消