0

3 つの画像ボタンがオンになっているマスター ページがあります。マスターページの下のコンテンツにはリストボックスがあり、リストの項目を選択すると、コンテンツに新しいリストが開きます。問題は、選択するとページ全体がリロードされ、画像を含むマスターページがリロードされ、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>
4

1 に答える 1

0

部分的なポストバック (AKA: AJAX ) を実行して、残りのページ要素を削除し、リスト要素から必要な動作を維持する必要があります。

A- jquery を使用して変更された値をキャプチャし、Web サーバーに移動して、データを返します (高速で推奨されますが、いくつかの作業が必要です)。

いくつかの有用な例:

  1. http://jquerybyexample.blogspot.com/2012/04/how-to-populate-aspnet-dropdownlist.html
  2. ドロップダウン リストをストアド プロシージャの結果に再バインドする jQuery-AJAX
  3. http://amin-sayed.blogspot.com/2008/10/in-this-example-ill-demonstrate-how-to.html

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
于 2013-02-04T14:48:43.507 に答える