Tuesday, 10 July 2012

UpdatePanel in ASP.NET

ASPX :


<body>
    <form id="form1" runat="server">
      <div style="padding-top: 10px">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <fieldset>
                <legend>UpdatePanel</legend>
                <asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
                </fieldset>
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
        </div>

    </div>

    </form>
</body>


If you are using MASTER PAGE IN PROJECT ...Then you need ScriptManagerProxy 

You need only copy & paste of following two line with your <asp:Content> tag
 
<asp:ScriptManagerProxy ID="scriptmanagerproxy1" runat="server">
        </asp:ScriptManagerProxy>


C#:

protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "Refreshed at " +
            DateTime.Now.ToString();
        }

No comments:

Post a Comment