0

I have a master page with three image buttons on. In the content below the master page i have listboxes and when i make a selection of an item on the list it opens a new list in the content. The problem is that when i make a selection the whole page is reloaded and the master page with the images reloads and makes like 1 second to come back all together. This is not very convenient as you may understand and its not for personal use program. Is it possible to make the post back work only for the field below and leave the master page untouched?

master page:

<%@ 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 Answers1

0

you will need to do partial postbacks (AKA: AJAX) in order to untouch the rest of your page elements, and still have the needed behavior from the list element.

A- Use jquery to capture the changed value, go to your web-server, and return back with the data (fast, and recommended, but need some work)

some useful examples:

  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

B- Use an update panel around the controls that you need to update them without the rest of the page ( not that fast from a performance perspective, but extermly easy to implement)

  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
Community
  • 1
  • 1
Mohammed Swillam
  • 9,119
  • 4
  • 36
  • 47