Wednesday, May 8, 2013

Sample code for ajax update panel in

Here we call ajax in using script manager update panel. by using update panel we can update particular portion of page.
Sample code as below :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="">
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <br />
            <asp:Label ID="Label1" runat="server" Text="Label" Width="249px"></asp:Label><br />
            <br />
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <hr />       
            <asp:Label ID="Label2" runat="server" Text="Label" Width="249px"></asp:Label>
            <hr />
            <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
            <asp:PostBackTrigger ControlID="Button2"/>
            <br />
            <asp:Label ID="Label3" runat="server" Text="Label" Width="249px"></asp:Label><br />
            <br />
            &nbsp;<asp:Button ID="Button1" runat="server" Text="Refresh single label only" Width="233px" OnClick="Button1_Click" />
            <asp:Button ID="Button2" runat="server" Text="Refresh all" Width="233px" OnClick="Button2_Click" />


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        Label1.Text = DateTime.Now.ToString();
        Label2.Text = DateTime.Now.ToString();
        Label3.Text = DateTime.Now.ToString();
    protected void Button1_Click(object sender, EventArgs e)
    protected void Button2_Click(object sender, EventArgs e)

Ouptut :

Source code download : Download Source code

If you are searching life partner. your searching end with now offer free matrimonial website which offer free message, free chat, free view contact information. so register here : Free matrimonial website