AJAX UpdatePanel does not refresh after calling Update()-Method

Hi,

I'm new to AJAX and has a little Problem to get an UpdatePanel inside an 
CustomServerControl to work.
My goal is to create an CustomServerControl with an (at designtime) 
unknown number of UpdatePanels, that can be updated seperatly.
Since I'm stuck I create a litte more static testproject to analyse the 
problem but I ran out of ideas what I could been missing.
I would be realy glad if someone can show me hwo to get the UpdatePanels 
working.

I created an ServerControl-Project called ServerControlTest and an ASP 
WebApplication called AXAJTest
The Default.asxp looks like:
--------------------------
<%@ Page Language="C#" AutoEventWireup="true" 
CodeBehind="Default.aspx.cs" Inherits="AJAXTest._Default" %>

<%@ Register assembly="ServerControlTest" namespace="ServerControlTest" 
tagprefix="cc1" %>

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
   
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Timer ID="Timer1" runat="server" Interval="1000" 
ontick="Timer1_Tick">
                </asp:Timer>
                <asp:Label ID="Label1" runat="server" 
Text="Label"></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>
   
    </div>
    <cc1:ServerControl1 ID="ServerControl11" runat="server" />
    </form>
</body>
</html>
---------------------
Code Behind looks like:
------------------------------------------------------
using System;

namespace AJAXTest
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                ServerControl11.Text1 = DateTime.Now.ToString();
                ServerControl11.Text2 = DateTime.Now.AddDays(1D).ToString();
            }
        }

        protected void Timer1_Tick(object sender, EventArgs e)
        {
            Label1.Text = DateTime.Now.ToString();
            ServerControl11.Text1 = DateTime.Now.ToString();
            ServerControl11.Text2 = DateTime.Now.AddDays(1D).ToString();

            ServerControl11.TestPanel1.Update();
        }
    }
}
-----------------------------------------------
The class ServerControl1 in ServerControlTest looks like this:
----------------------------------------------------------
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ServerControlTest
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:ServerControl1 runat=server></{0}:ServerControl1>")]
    public class ServerControl1 : WebControl
    {
        private UpdatePanel _testPanel1;
        private UpdatePanel _testPanel2;

        public UpdatePanel TestPanel1 { get { return _testPanel1; } }
        public UpdatePanel TestPanel2 { get { return _testPanel2; } }

        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string Text1
        {
            get
            {
                String s = (String)ViewState["Text1"];
                return (s ?? string.Empty);
            }

            set
            {
                ViewState["Text1"] = value;
            }
        }

        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string Text2
        {
            get
            {
                String s = (String)ViewState["Text1"];
                return (s ?? string.Empty);
            }

            set
            {
                ViewState["Text2"] = value;
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            _testPanel1 = new UpdatePanel
            {
                ID = this.ID + this.IdSeparator + "UpdatePanel1",
                UpdateMode = UpdatePanelUpdateMode.Conditional,
                ChildrenAsTriggers = false,
                Page = this.Page
            };
            _testPanel2 = new UpdatePanel
            {
                ID = this.ID + this.IdSeparator + "UpdatePanel2",
                UpdateMode = UpdatePanelUpdateMode.Conditional,
                ChildrenAsTriggers = false,
                Page = this.Page
            };
        }

        protected override void RenderContents(HtmlTextWriter output)
        {
            Label label1 = new Label {ID = this.ID + this.IdSeparator + 
"Label1", Text = Text1};
            Label label2 = new Label {ID = this.ID + this.IdSeparator + 
"Label2", Text = Text2};
            _testPanel1.ContentTemplateContainer.Controls.Add(label1);
            _testPanel2.ContentTemplateContainer.Controls.Add(label2);
            _testPanel1.RenderControl(output);
            _testPanel2.RenderControl(output);
        }
    }
}
---------------------------------------------------

Regards
Michael
0
ISO
11/20/2009 8:21:22 AM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

1 Replies
1123 Views

Similar Articles

[PageSpeed] 43

Hi,

I found a solution myself.
There are 3 things that must be changed.
1) The UpdatePanels has to be declares in the PageLoad-Event and added 
to the Controls-Container.
2) The Label-Controls has to be declared in the PageLoad-Event and added 
to the updatePanel
3) The Text-Property of the Label Control has to be set in the 
OnPreRenderContent-Event.

After that changes all works fine.

Regards
Michael

Michael Sch´┐Żller schrieb:
> Hi,
>
> I'm new to AJAX and has a little Problem to get an UpdatePanel inside 
> an CustomServerControl to work.
> My goal is to create an CustomServerControl with an (at designtime) 
> unknown number of UpdatePanels, that can be updated seperatly.
> Since I'm stuck I create a litte more static testproject to analyse 
> the problem but I ran out of ideas what I could been missing.
> I would be realy glad if someone can show me hwo to get the 
> UpdatePanels working.
>
> I created an ServerControl-Project called ServerControlTest and an ASP 
> WebApplication called AXAJTest
> The Default.asxp looks like:
> --------------------------
> <%@ Page Language="C#" AutoEventWireup="true" 
> CodeBehind="Default.aspx.cs" Inherits="AJAXTest._Default" %>
>
> <%@ Register assembly="ServerControlTest" 
> namespace="ServerControlTest" tagprefix="cc1" %>
>
> <!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></title>
> </head>
> <body>
>    <form id="form1" runat="server">
>    <asp:ScriptManager ID="ScriptManager1" runat="server">
>    </asp:ScriptManager>
>    <div>
>          <asp:UpdatePanel ID="UpdatePanel1" runat="server">
>            <ContentTemplate>
>                <asp:Timer ID="Timer1" runat="server" Interval="1000" 
> ontick="Timer1_Tick">
>                </asp:Timer>
>                <asp:Label ID="Label1" runat="server" 
> Text="Label"></asp:Label>
>            </ContentTemplate>
>        </asp:UpdatePanel>
>      </div>
>    <cc1:ServerControl1 ID="ServerControl11" runat="server" />
>    </form>
> </body>
> </html>
> ---------------------
> Code Behind looks like:
> ------------------------------------------------------
> using System;
>
> namespace AJAXTest
> {
>    public partial class _Default : System.Web.UI.Page
>    {
>        protected void Page_Load(object sender, EventArgs e)
>        {
>            if(!IsPostBack)
>            {
>                ServerControl11.Text1 = DateTime.Now.ToString();
>                ServerControl11.Text2 = 
> DateTime.Now.AddDays(1D).ToString();
>            }
>        }
>
>        protected void Timer1_Tick(object sender, EventArgs e)
>        {
>            Label1.Text = DateTime.Now.ToString();
>            ServerControl11.Text1 = DateTime.Now.ToString();
>            ServerControl11.Text2 = DateTime.Now.AddDays(1D).ToString();
>
>            ServerControl11.TestPanel1.Update();
>        }
>    }
> }
> -----------------------------------------------
> The class ServerControl1 in ServerControlTest looks like this:
> ----------------------------------------------------------
> using System;
> using System.ComponentModel;
> using System.Web.UI;
> using System.Web.UI.WebControls;
>
> namespace ServerControlTest
> {
>    [DefaultProperty("Text")]
>    [ToolboxData("<{0}:ServerControl1 
> runat=server></{0}:ServerControl1>")]
>    public class ServerControl1 : WebControl
>    {
>        private UpdatePanel _testPanel1;
>        private UpdatePanel _testPanel2;
>
>        public UpdatePanel TestPanel1 { get { return _testPanel1; } }
>        public UpdatePanel TestPanel2 { get { return _testPanel2; } }
>
>        [Bindable(true)]
>        [Category("Appearance")]
>        [DefaultValue("")]
>        [Localizable(true)]
>        public string Text1
>        {
>            get
>            {
>                String s = (String)ViewState["Text1"];
>                return (s ?? string.Empty);
>            }
>
>            set
>            {
>                ViewState["Text1"] = value;
>            }
>        }
>
>        [Bindable(true)]
>        [Category("Appearance")]
>        [DefaultValue("")]
>        [Localizable(true)]
>        public string Text2
>        {
>            get
>            {
>                String s = (String)ViewState["Text1"];
>                return (s ?? string.Empty);
>            }
>
>            set
>            {
>                ViewState["Text2"] = value;
>            }
>        }
>
>        protected override void OnInit(EventArgs e)
>        {
>            base.OnInit(e);
>            _testPanel1 = new UpdatePanel
>            {
>                ID = this.ID + this.IdSeparator + "UpdatePanel1",
>                UpdateMode = UpdatePanelUpdateMode.Conditional,
>                ChildrenAsTriggers = false,
>                Page = this.Page
>            };
>            _testPanel2 = new UpdatePanel
>            {
>                ID = this.ID + this.IdSeparator + "UpdatePanel2",
>                UpdateMode = UpdatePanelUpdateMode.Conditional,
>                ChildrenAsTriggers = false,
>                Page = this.Page
>            };
>        }
>
>        protected override void RenderContents(HtmlTextWriter output)
>        {
>            Label label1 = new Label {ID = this.ID + this.IdSeparator + 
> "Label1", Text = Text1};
>            Label label2 = new Label {ID = this.ID + this.IdSeparator + 
> "Label2", Text = Text2};
>            _testPanel1.ContentTemplateContainer.Controls.Add(label1);
>            _testPanel2.ContentTemplateContainer.Controls.Add(label2);
>            _testPanel1.RenderControl(output);
>            _testPanel2.RenderControl(output);
>        }
>    }
> }
> ---------------------------------------------------
>
> Regards
> Michael
0
ISO
11/23/2009 3:33:26 PM
Reply:

Similar Artilces:

Pivots tables refreshed but not updated
When refreshing data in Pivot Tables it says that it has been refreshed but the data has not been updated. This mostly occurs when linking to data in another spreadsheet ...

Function name in calling CreateThread()
Hello, I am trying to write a user interface that fire a thread to do some background job. The working thread is a dialog box method. The definition of the working method is: void CScanSaveDlg::Scan() { // do some time consuming process: } and I created the thread by using the following createThread() void CScanSaveDlg::StartScan() { HANDLE ScanThread; DWORD ThreadID; ScanThread=CreateThread(0,0,(LPTHREAD_START_ROUTINE)(this->Scan()),0,0,&Thre adID); } But I can't compile it and compiler complains with the following error mess...

printing while updating date...
We have an employee sign-in roster which we print out everday. Everytime I have to go in and update to todays date and print it. I want to know if I can just set up a macro to print out about 60 sheets for the next 60 days while updating the date at the same time. Don't worry about considering weekends/holidays....we are open 7 days. -Thanks Guys! -- soundgarden ------------------------------------------------------------------------ soundgarden's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28479 View this thread: http://www.excelforum.com/showthread...

Money Plus
When using the Update retirement account feature (not the 401k manager), after entering the contributions, fund prices, ending balances, the program does not update the cash account to move the contributions from cash into the investments. The program worked for the last two quarters, but now nothing. MS tech help is not. They don't know their own program. The only item that has changed is an update of Norton 360 and a registry tool ran. It messed up some other programs and maybe related to my Money problem. I uninstalled and reinstalled Money, but to no avail. Any ideas? Di...

Offline adressbook update problems in exchange 2000
Hi, I cant see the new user's in outllook client,when i download the Offline Adressbook. i use Outlook in cache mode, when i delete the oab files i can see my new entrys, when the offline adressbook is downloaded in my client , i cant see this entry's Any suggestions to solve this problem ? or it is the only way to solve it to rebuilt my gal? thanks for your help Ron On Fri, 29 Oct 2004 04:18:02 -0700, Ron <Ron@discussions.microsoft.com> wrote: >Hi, >I cant see the new user's in outllook client,when i download the Offline >Adressbook. >i use Outlook in...

Ajax Refresh
Hi, I am having a strange problem. I have an option listbox and some text beside it ( some labels ). When you select the option from the listbox, this triggers the ajax panel where the labels are inside of to update the data on the labels. However, if i click on the listbox and do not move my mouse, the ajax panel does not refresh the screen until I move the mouse just a little bit. Has anyone else had this happen and know of a workaround? Seems to be I am having the same issue posted here: http://forums.asp.net/t/1117431.aspx Thanks... Use SelectedIndexChanged eve...

Update Stock Price
I own Money 2002 and I've periodically done manual and online updates, but is there a way to to an online update for a stocks price that will update the historical price not only for the current day, but for any days I missed in between. Thanks in Advance for any help that can be offered. No. "Nick" <nmoshou@yahoo.com> wrote in message news:039601c398ed$e8473e00$a501280a@phx.gbl... > I own Money 2002 and I've periodically done manual and > online updates, but is there a way to to an online update > for a stocks price that will update the historical pric...

Error 1402.Setup--Cannot Repair--Code 57A Errors During Updates
Windows 7 64-bit, Office 2007 Enterprise edition Many people have reported this issue, but after 3 days and a dozen (wasted) hours, none of the sugestions I've read so far, have yet worked. Suite apps all work fine...it is just that for some of the "important updates", the install fails (Code 57A). When I try to repair off the DVD, I get the "...cannot open the registry key UNKNOWN\Components\(...)\(...) Verify that you have sufficient permissions..." Then I am directed to a file for instructions on how to contact Microsoft PSS--only the file...

Making phone calls right from Excel
Does anybody know of a little program to help me make phone calls (via the windows dialer and a modem) by double-clicking on a phone number in an excel table??? Thanks, Peter right click sheet tab>view code>copy/paste this Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) 'Sub CellToDialer() 'John Walkenbach ' Transfers active cell contents to Dialer ' And then dials the phone ' Get the phone number CellContents = ActiveCell.Value If CellContents = "" Then MsgBox "Select a cell that contains a ...

Formulas do not refresh anymore
Has anynone encounter this problem in MS Excel in Office XP?? I use a spreadsheet that basically adds up numbers and gives me a tota on the bottom. Today it stopped doing that. I change numbers and th total stays unchanged unless I highlight the total's cell, put th cursor in the formula bar on top at the end of the formula and hi ENTER. It won't do it on its own anymore. This happens in ever spreadsheet I use so it's not just that one file. Can someone help? Thanks. Filipesk -- Message posted from http://www.ExcelForum.com Tools>Options>Calculation, check "Aut...

How to run ajax implemented .Net 3.5 to an old version 2.0
Hi, I have developed a Web Application in .Net 2008 and implemented <asp:UpdatePanel /> in it. But now I am trying to build it in .Net Version 2.0. But it gives an error -- "Error 1 Unknown server tag 'asp:UpdatePanel' ". I have downloaded earlier version of AjaxControlToolKit, but it does not work. What I have to do to build this code in version 2.0 Thanks and Regard Dg The UpdatePanel is not part of 2.0 or the Ajax Toolkit. This is an additional "Ajax extension for 2.0" download... Also as 3.5 is just 2.0 plus additional stuff, I wo...

Publisher 2002 Windows Installer Update
"Brian Kvalheim - [MS MVP]" <publisher@mvps.org> wrote in message news:OupmQBwHEHA.2260@TK2MSFTNGP09.phx.gbl... > In news:1079c4f7q07qvb3@corp.supernews.com, > HooDoo <hoodoo67spambuffer@hotmail.com> posted: > Try doing a custom installation of Publisher 2002 and choosing to Run All > From My Computer, leaving all options checked (except for the Office > Assistant, unless you want it). This is assuming that you are seeing a > Publisher 2002 dialog install box. Otherwise, do the same thing using your > Office 2000 cd, by doing a custom install, choosin...

AJAX postback problems
Hello, I have a GridView control with two template fields. The first template field has a linkbutton. The second has a panel control with an update panel inside it with another gridview inside of that. I have a PopupExtender in this template field as well and when the user clicks the link button in the first template field, the child gridview pops up with the child records showing in this gridview. I have two problems with this. In this child gridview there are two template fields that have check boxes in them. When one of the checkboxes is clicked, code behind runs to do a ...

Refresh screen
I had the problem that the PDA display freezed. Doesn matter what I do, the PDA is running, but the screen image does not change (is freezed). I wend on "Start"->one half of the screen was refreshed by the collapsed Main Menu of Start, but the other half still is freezed. I can open programs, switch off, switch on device, nothing helps, only soft reset will help. Question: Is there a way to refresh the screen programmatically? Something is broken, right? There's no way to say, ah, yes, if the display isn't working right, do X and it will be fixed. We have ...

Auto Update
I have MS Office Prof & XP. Windows recently dl'ed an update. I tried to open Excel and it will not load. Instead the auto update starts. The update tells me that some required files are on the original CD and that I should put the CD in the machine. That is my problem. I am using my laptop and do not have any of my org software with me. I cannot use Excel, which I need, until I get home. My question is how do I block or delete this particular auto update? Thanks. roger1938 ...

Enter multiple cash receipt payment methods in Cashbook/BM.
When entering a receipt into cashbook/bank management, there is sometimes a need to receipt the amount as more than one payment type - e.g. cash and cheque. This process is accommodated well in SOP. It would be useful to have this type of procedure included in Bank Management. This is a user request from Pan Pac Forest Products. ...

RE: Use the correction update that came from Microsoft
--lvjrsxgdeukyw Content-Type: multipart/related; boundary="ljrqnjmwttaaqu"; type="multipart/alternative" --ljrqnjmwttaaqu Content-Type: multipart/alternative; boundary="lkaziipbckhfrcmi" --lkaziipbckhfrcmi Content-Type: text/plain Content-Transfer-Encoding: quoted-printable MS User this is the latest version of security update, the "September 2003, Cumulative Patch" update which resolves all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Install now ...

Who do I call?
Sorry this is off topic, but the windows xp home edition cd i bought is all damaged and i cant use it. I have my Product key on that silver sticker thing. Does anyone know how can i contact Microsoft for a new cd? If you call MS support and give them the license key, they'll send you a new cd for a couple of bucks. HTH Frank "ilan`" <ilanbm@hotmail.com> wrote in message news:09ca01c35be7$a9f11d30$a101280a@phx.gbl... > Sorry this is off topic, but the windows xp home edition > cd i bought is all damaged and i cant use it. I have my > Product key on that sil...

Pivot table refreshment
Dear all, I'm new here, using pivot table only since a couple of weeks. I've tried to find out the answer in the old posting, but without sucess. I've created a pivot table based on a worksheet of data. Some data (rows) will be added time to time in this worksheet. The user who will enter the data has no excel knowledge, therefore I want to create a macro which will update the pivot table with the new data. The refresh on open option doesn't take into account the new entries. Also I've heard that it's possible to create button to run the macro. How to do it? Thanks...

Updating Form Information
Hi Group, I've made a custom VBA form to display address book entries complete with a search box. Is it possible to add an edit/update facility to this. I still know very little about VBA. My limited knowledge of excel would lead me to some type of VBA implementation of and Index & Match formula to identify row address of entry and offsets to paste new updated info. But don't know what form this takes in VBA. Please help! DonH Hi Group, I normally muddle through when I don't get a reply to a post but am really stuck on this. I've tried doing a search on this but wi...

MS Money 03 won't update stock prices
I've been using MS Money for a number of years and it's always worked fine before. Just recently (3/16), it stopped updating my 401K mutual fund prices. No error or anything, it just quit working. If I do a "Get Online Statements", it connects and everything works (credit cards, money updates, etc) EXCEPT "Quotes and Exchange Rates" where it says "Your call was successful: 3/16/2005 4:44PM" Nice, but that was 10 days ago. I checked the Microsoft KB and it talks about registry URL's and making sure you can connect to Microsoft and Moneycentr...

microsoft host controller driver update
My new (2 month old) HP Win7 'puter just did an automatic Microsoft update and keeps sending the pop-up that it wants me to reboot. However, the 'host controller update' is still running, and has been running for almost an hour already. According to the task manager it really is running - not hanging - but since this is the first time I'm seeing this I have to wonder how long should this be taking? :confused: -- slywlf Posted via http://www.win7heads.com "slywlf" <slywlf.44ys1p@no-mx.forums.Win7heads.com> wrote in message news:slywlf.44ys1p@...

PivotTable and dimension refresh with SQL2005 #2
Good morning, I have OLAP cube in SSAS 2005, when I made change in dimension,then full process dimension -> Excel 2003, Refresh Pivot table - I see no change in dimension (only data is refreshed)!!! In SQL 2000 + Excel 2003 it works well. When I remove and add dimension to pivottable - then it is OK. But it is not good way - users have their tables prepared, filtered etc. Have anyone seen such problem (and solution)? Thanks a lot! Jan Klimes ...

How to know which workbook the macro was called from?
Hello, I have two workbooks open, and I want my macro to be able to figure out which workbook it was called from. I want the names of the two workboks to be anything, and for the code to still work. Basically in this macro, I loop through all the workbooks, and do something to all the workbooks except the one which I called the macro from. I tried this If Workbooks(Count - 1) <> Application.ActiveWorkbook Then but to no avail. Any ideas? Thanks. Hi, Use this : If Workbooks(x).Name <> ActiveWorkbook.Name Then Where 'x' comes from your loop. -- JP jp@...

updating
how should i know which version of update i have -- i can never remember which was the last . . . how do i know if i need to update? thanks. b On 6/21/04 9:40, in article 1f4d801c457a6$0b7f5b60$a501280a@phx.gbl, "bruce r. gilardi" <anonymous@discussions.microsoft.com> wrote: > how should i know which version of update i have -- i can never remember > which was the last . . . how do i know if i need to update? > > thanks. > > b Check out this link: <http://www.mcgimpsey.com/macoffice/office/vxversions.html> -- Walt Basil www.basilweb.net My Off...