在母版页中,只应回发内容页,而应避免回发母版页. [英] In Masterpage, only content page should be posted back, and posting back of master page should be avoided.

查看:118
本文介绍了在母版页中,只应回发内容页,而应避免回发母版页.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.net 3.5网站,在其中我使用一个母版页拥有多个.aspx页.每次页面重定向时都会遇到问题.

我在主页上有一个标题,其中网站标题显示为图像.

在此之下,我有一个内容占位符,用于显示所有内容页面.

现在,我在内容页面1中有一个按钮,该按钮重定向到内容页面2.当我单击按钮时,它将重定向到页面2,但整个母版页都将发布回服务器.我需要的是内容页面仅需要回发.应避免回发母版页.

请在这方面帮助我.
以下是我的母版页的标记.

I have a .net 3.5 website in which I''m having several .aspx pages using a single master page. I''m facing an issue every time the pages are redirected.

I have a header in the master page where the title of website is displayed as image.

beneath that I have a content placeholder where all the content pages are displayed.

Now, I have a button in content page1 which redirects to content page2. When I click on the button it is redirecting to page 2 but the whole master page is posting back to the server. What I need is the content page only need to be posted back. posting back of master page should be avoided.

Please help me in this regard.
below is the markup of my master page.

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>
<!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">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
<link href="StyleSheets/StyleMaster.css" rel="Stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
<table id="tblMasterHeader" class="headBar" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td class="headLogo">
                <asp:HyperLink ID="HomeLink" runat="server" NavigateUrl="Aboutus.aspx" BorderStyle="None"

                    BorderWidth="0px">
                    <asp:Image ID="Image1" ImageUrl="Images/Masterpage/Logo1.png" BorderStyle="None"

                        runat="server" />
                </asp:HyperLink>
            </td>
            <td style="height: 100%">
                <table width="100%" border="0" style="height: 100%">
                    <tr>
                        <td class="aboveMenuBar">
                            <%--Top space--%>
                            <label id="lblTime" runat="server">
                            </label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%--Menu Bar--%>
                            <asp:Menu ID="mnuMain" runat="server" Orientation="Horizontal" DataSourceID="SiteMapMain"

                                StaticItemFormatString="//{0} &nbsp;&nbsp;&nbsp; ">
                                <StaticHoverStyle CssClass="MenuControlNoHover" />
                            </asp:Menu>
                            <asp:SiteMapDataSource ID="SiteMapMain" runat="server" ShowStartingNode="False" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
        </tr>
    </table>
    <table class="MasterContent">
        <tr>
            <td class="MasterLeftPanel">
                This is left panel
            </td>
            <td valign="top">
                <asp:ContentPlaceHolder ID="MainContent" runat="server">
                </asp:ContentPlaceHolder>
            </td>
        </tr>
    </table>
    <table class="MasterFooter">
        <tr>
            <td>
                This is footer
            </td>
        </tr>
    </table>
    </form>
</body>
</html>



请帮帮我.



Please help me.
Thanks in anticipation.

推荐答案

如果您的意思是只希望更新页面的一部分(而不是整个页面),则需要使用AJAX来提供部分页面渲染.
[
If you mean you only want one part of the page updated (instead of the whole thing) you will need to use AJAX to provide partial page rendering.
This[^] is a microsoft tutorial on how to achieve it.


这篇关于在母版页中,只应回发内容页,而应避免回发母版页.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆