禁用母版页上的回发刷新

时间:2013-02-04 14:41:55

标签: asp.net master-pages

我有一个主页面上有三个图像按钮。在母版页下面的内容中,我有列表框,当我在列表中选择一个项目时,它会在内容中打开一个新列表。问题在于,当我进行选择时,整个页面被重新加载,并且带有图像的母版页重新加载并使得像1秒钟一起回来。这可能不太方便,因为您可能理解,它不是个人使用程序。是否可以使帖子仅用于下面的字段并保持母版不变?

母版页:

<%@ Master Language="VB"  CodeFile="MyMasterPage.master.vb" Inherits="MyMasterPage" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div id="topContent" align="center">
        <table>
            <tr>
                <td style="width:400px;" align="right" axis="top">
                </td>
                <td>
                            <asp:Image ID="Image1" runat="server" ImageUrl="~/PetrolinaLetters.png" />
                </td>
                <td style="width:400px; text-align:center;" valign="top">
                <asp:Label ID="userText" runat="server" BorderStyle="Double" Width="130px" Font-Bold="True"></asp:Label>
                </td>
            </tr>
        </table>
        <div>
            <table>
                <tr>
                    <td style="width:170px;">
                        <asp:ImageButton ID="ImageButton1" runat="server" Height="30px" ImageUrl="~/orderButton.png"
                            Width="160px" />
                    </td>
                    <td style="width: 170px;">
                        <asp:ImageButton ID="ImageButton2" runat="server" Height="30px" ImageUrl="~/orderHistory.png"
                            Width="160px" />
                    </td>
                    <td style="width:170px;">
                        <asp:ImageButton ID="ImageButton3" runat="server" Height="30px" ImageUrl="~/changePass.png"
                            Width="160px" />
                    </td>
                </tr>
            </table>
        </div>
        <br />
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

您需要进行部分回发(AKA: AJAX )才能取消其余的页面元素,并且仍然具有list元素中所需的行为。

A-使用jquery捕获更改的值,转到您的Web服务器,然后返回数据(快速,推荐,但需要一些工作)

一些有用的例子:

  1. http://jquerybyexample.blogspot.com/2012/04/how-to-populate-aspnet-dropdownlist.html
  2. jQuery-AJAX to rebind dropdown list to results from stored procedure
  3. http://amin-sayed.blogspot.com/2008/10/in-this-example-ill-demonstrate-how-to.html
  4. B-在没有页面其余部分的情况下使用您需要更新它们的控件的更新面板(从性能角度来看不是那么快,但是很容易实现)

    1. http://www.asp.net/web-forms/tutorials/aspnet-ajax/understanding-asp-net-ajax-updatepanel-triggers
    2. http://www.asp.net/ajax/documentation/live/tutorials/IntroductionUpdatePanel.aspx
    3. http://www.netrostar.com/How-to-Use-NET-Update-Panel