Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi , I am having two update panels -panel1 and panel2 and a timer to update panel1 but timer updates both the update panel..
 
Here is the code..
 
protected void Page_Load(object sender, EventArgs e)
    {
        lbl_Date.Text = DateTime.Now.ToString();
        lbl_Date0.Text = DateTime.Now.ToString();
        lbl_Date1.Text = DateTime.Now.ToString();
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        lbl_Date0.Text = DateTime.Now.ToString();
    }
 

 

 
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<!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>
                <asp:Label ID="lbl_Date" runat="server" Text="Label"> </asp:Label>
                <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
            </div>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <br />
            <br />
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            &nbsp;<asp:Button ID="Button1" runat="server" Text="Button" />
 

            <br />
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
                    <asp:Timer ID="Timer1" runat="server" Interval="1000">
                    </asp:Timer>
                    <br />
                    <asp:Label ID="lbl_Date0" runat="server" Text="Label"> </asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>
            <br />
            <br />
            <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                <ContentTemplate>
                    <br />
                    <asp:Label ID="lbl_Date1" runat="server" Text="Label"> </asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>
 

    <br />
    </form>
</body>
</html>
Posted 24-Sep-12 4:54am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Put UpdateMode="Conditional" in both the Update panels next to their ID's defined.
 
Refer, details here: MSDN: UpdatePanel.UpdateMode Property [^]
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 278
1 Maciej Los 245
2 Nguyen.H.H.Dang 230
3 Peter Leow 195
4 arvind mepani 187


Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 24 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid