Update Panel With Asp.Net

Posted by Fundaravi under ASP.NET AJAX on 2/29/2012 | Points: 10 | Views : 1467 | Status : [Member] | Replies : 2
In Ajax I have two update panel controls and two buttons is there.
If i click on first button only first update panel will fired.
If i click on second button only second update panel will fired.How?

Ravindra


Responses

Posted by: Sksamantaray on: 2/29/2012 [Member] Silver | Points: 25

Up
0
Down

Hi, Try this.

<form id="form1" runat="server">

<div>
<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 />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>


<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label2" runat="server" Text="Panel2 created."></asp:Label><br />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
</form>

//code behind
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "";
Label1.Text = DateTime.Now.ToLongTimeString();

}
protected void Button2_Click(object sender, EventArgs e)
{
Label2.Text = "";
Label2.Text = DateTime.Now.ToLongTimeString();

}


Thanks,
Sanjay

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/1/2012 [Member] Bronze | Points: 25

Up
0
Down

<form id="form1" runat="server">

<div>

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

<ContentTemplate>

<fieldset>

<legend>UpdatePanel</legend>

<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />

</fieldset>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="Button" />

</Triggers>

</asp:UpdatePanel>

<asp:Button ID="Button1" runat="server" OnClick="Button_Click" Text="Button" /></div>





<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">

<ContentTemplate>

<fieldset>

<legend>UpdatePanel</legend>

<asp:Label ID="Label2" runat="server" Text="Panel2 created."></asp:Label><br />

</fieldset>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="Button" />

</Triggers>

</asp:UpdatePanel>

<asp:Button ID="Button2" runat="server" OnClick="Button_Click" Text="Button" />

</form>



//code behind

protected void Button_Click(object sender, EventArgs e)

{

Label1.Text = "";
Label2.Text = "";

Label1.Text = DateTime.Now.ToLongTimeString();

Label2.Text = DateTime.Now.ToLongTimeString();

}


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Fundaravi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response