473,545 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update Panel not updating DOM

I have an asp.net page that contains an update panel. Within the update
panel, controls get added dynamically. During partial page post backs the
controls within the panel will change.

I have a javascript function that uses the ClientID of the dynamic controls
to perform certain operations on the client-side. With each partial page post
back, I dynamically recreate the javascript function using the ClientIDs of
the newly added controls. I use ScriptManager.R egisterStartupS cript to add
the newly created script to the page.

Using debug, I stepped through and I can see that the controls and
javascript are all getting created correctly.

The javascript function runs correctly on the initial page load. But, on a
partial page postback, it is throwing a null exception in the client
javascript because it is searching for a ClientID that does not exist.

The DOM does not get updated with the new ClientIDs.

How can I force the DOM to update on a partial page postback?
Oct 10 '08 #1
2 5687
Hi,

I cannot reproduce this problem. My test code:

Aspx:
<asp:ScriptMana ger ID="ScriptManag er1" runat="server">
</asp:ScriptManag er>
<asp:UpdatePane l ID="UpdatePanel 1" runat="server">
<ContentTemplat e>
<asp:Panel ID="Panel1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Change
Control"
onclick="Button 1_Click" />
<asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label>
</asp:Panel>

</ContentTemplate >
</asp:UpdatePanel >

Aspx.cs:
protected void Page_PreRender( object sender, EventArgs e)
{

if (!IsPostBack)
{
ScriptManager.R egisterStartupS cript(this.Upda tePanel1,
typeof(UpdatePa nel), "allen"," <script type='text/javascript'>
alert(document. getElementById( '" +
this.Label1.Cli entID + "').tagName )</script>", false);

}
}
protected void Button1_Click(o bject sender, EventArgs e)
{
TextBox t=new TextBox();
this.Panel1.Con trols.Clear();
this.Panel1.Con trols.Add(t);
t.ID = "TextBox1";
ScriptManager.R egisterStartupS cript(this.Upda tePanel1,
typeof(UpdatePa nel), "allen"," <script type='text/javascript'>
alert(document. getElementById( '" + t.ClientID + "').tagName )</script>",
false);

}

In the first page load you can see the message box showing "SPAN". If you
click the button you'll see "INPUT".
Could you test my code? Look forward to your test result.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Thread-Topic: Update Panel not updating DOM
| thread-index: Ackqtv8n/5lXEfiiTgmq62x9 4GasSw==
| X-WBNR-Posting-Host: 207.46.192.207
| From: =?Utf-8?B?TUNN?= <MC*@newsgroup. nospam>
| Subject: Update Panel not updating DOM
| Date: Fri, 10 Oct 2008 02:03:01 -0700
| Lines: 20
| Message-ID: <50************ *************** *******@microso ft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.3119
| Newsgroups: microsoft.publi c.dotnet.genera l
| Path: TK2MSFTNGHUB02. phx.gbl
| Xref: TK2MSFTNGHUB02. phx.gbl microsoft.publi c.dotnet.genera l:23096
| NNTP-Posting-Host: tk2msftibfm01.p hx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
| I have an asp.net page that contains an update panel. Within the update
| panel, controls get added dynamically. During partial page post backs the
| controls within the panel will change.
|
| I have a javascript function that uses the ClientID of the dynamic
controls
| to perform certain operations on the client-side. With each partial page
post
| back, I dynamically recreate the javascript function using the ClientIDs
of
| the newly added controls. I use ScriptManager.R egisterStartupS cript to
add
| the newly created script to the page.
|
| Using debug, I stepped through and I can see that the controls and
| javascript are all getting created correctly.
|
| The javascript function runs correctly on the initial page load. But, on
a
| partial page postback, it is throwing a null exception in the client
| javascript because it is searching for a ClientID that does not exist.
|
| The DOM does not get updated with the new ClientIDs.
|
| How can I force the DOM to update on a partial page postback?
|

Oct 13 '08 #2
Thank you for your help. In the process of trying to replicate the bug for
you, I figured out the problem. I have the controls in separate UpdatePanels.
The UpdateMode was set to Conditional. So when the ClientIDs would change,
they never get pushed to the client.
"Allen Chen [MSFT]" wrote:
Hi,

I cannot reproduce this problem. My test code:

Aspx:
<asp:ScriptMana ger ID="ScriptManag er1" runat="server">
</asp:ScriptManag er>
<asp:UpdatePane l ID="UpdatePanel 1" runat="server">
<ContentTemplat e>
<asp:Panel ID="Panel1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Change
Control"
onclick="Button 1_Click" />
<asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label>
</asp:Panel>

</ContentTemplate >
</asp:UpdatePanel >

Aspx.cs:
protected void Page_PreRender( object sender, EventArgs e)
{

if (!IsPostBack)
{
ScriptManager.R egisterStartupS cript(this.Upda tePanel1,
typeof(UpdatePa nel), "allen"," <script type='text/javascript'>
alert(document. getElementById( '" +
this.Label1.Cli entID + "').tagName )</script>", false);

}
}
protected void Button1_Click(o bject sender, EventArgs e)
{
TextBox t=new TextBox();
this.Panel1.Con trols.Clear();
this.Panel1.Con trols.Add(t);
t.ID = "TextBox1";
ScriptManager.R egisterStartupS cript(this.Upda tePanel1,
typeof(UpdatePa nel), "allen"," <script type='text/javascript'>
alert(document. getElementById( '" + t.ClientID + "').tagName )</script>",
false);

}

In the first page load you can see the message box showing "SPAN". If you
click the button you'll see "INPUT".
Could you test my code? Look forward to your test result.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Thread-Topic: Update Panel not updating DOM
| thread-index: Ackqtv8n/5lXEfiiTgmq62x9 4GasSw==
| X-WBNR-Posting-Host: 207.46.192.207
| From: =?Utf-8?B?TUNN?= <MC*@newsgroup. nospam>
| Subject: Update Panel not updating DOM
| Date: Fri, 10 Oct 2008 02:03:01 -0700
| Lines: 20
| Message-ID: <50************ *************** *******@microso ft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.3119
| Newsgroups: microsoft.publi c.dotnet.genera l
| Path: TK2MSFTNGHUB02. phx.gbl
| Xref: TK2MSFTNGHUB02. phx.gbl microsoft.publi c.dotnet.genera l:23096
| NNTP-Posting-Host: tk2msftibfm01.p hx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
| I have an asp.net page that contains an update panel. Within the update
| panel, controls get added dynamically. During partial page post backs the
| controls within the panel will change.
|
| I have a javascript function that uses the ClientID of the dynamic
controls
| to perform certain operations on the client-side. With each partial page
post
| back, I dynamically recreate the javascript function using the ClientIDs
of
| the newly added controls. I use ScriptManager.R egisterStartupS cript to
add
| the newly created script to the page.
|
| Using debug, I stepped through and I can see that the controls and
| javascript are all getting created correctly.
|
| The javascript function runs correctly on the initial page load. But, on
a
| partial page postback, it is throwing a null exception in the client
| javascript because it is searching for a ClientID that does not exist.
|
| The DOM does not get updated with the new ClientIDs.
|
| How can I force the DOM to update on a partial page postback?
|

Oct 13 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1302
by: ManConfusedByMouse | last post by:
Hi all, I AM HAVING PROBLEMS UNDERSTANDING THE UPDATING BEHAVIOR/TIMING OF A WINDOWS.FORMS.SCROLLBAR COMPONENT... quick apology for my sorry posterior if posting in wrong place -- haven't much experience with these groups, and can find nothing more specific than csharp. my program manually sets up some synchronization between the user's...
2
4941
by: rodchar | last post by:
hey all, i saw an update panel example one time where they put a button outside the update panel and a textbox inside the panel and setup a trigger on the update panel to update when the button was clicked. well, i'm trying to do the same thing except with a datalist but i can't get it to work. i have a link button in my item template of my...
8
5340
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In this code there is a panel panel1, that I populate with a lable in the foreground. Then when I click on "button1" a backgroundworker thread in async...
1
1705
by: manojuniverse | last post by:
Hi, I am using update panel of asp.net 2.0 ajax to implement ajax. I have structure like this (.aspx file) <update panel id=_updatelpanel> <contenttemplate> <table1>
3
9305
by: ma | last post by:
Hello, I have two update Panel in my page. I want to update one of these update panels from another one. How can I do this? How can I force the whole page to be updated from a button inside an update panel? Regards
1
1381
by: Microsoft Newsserver | last post by:
HI Im developing a solution in vs2005 with ajex extensions. Essentially I have three custom controls which render tables a representation as shown below. The problem is that when any of those buttons get clicked all three tables are updated. ( Buttons 1 2 and 3 are outside the panels ). How can I get ONLY the relevent panel to update ??
1
1653
by: =?Utf-8?B?S2VuIEFkZW5pamk=?= | last post by:
I read, How can I update my user interface from a thread that did not create it? http://blogs.msdn.com/csharpfaq/archive/2004/03/17/91685.aspx I have a postback event handler, that requests user input via JavaScript confirm methods to process conditional steps. After completing asynchronous processing, binding the result sets to the...
0
1145
by: ra220511 | last post by:
hello ive only started using ajax for first time today . i am trying to use an update panel in asp.net but my whole page keeps refresh rather than just the content area. can any one help. <asp:Panel id="pnlQA" runat="server"> <asp:UpdateProgress ID="upcQuestionnaire" runat="server"> ...
14
2404
by: Adam Sandler | last post by:
I have a class with a method which returns a panel. The panel was not created with the visual editor, I coded it by hand -- because some of the content on the panel can be dynamic and thus I chose to do it that way. At any rate, I have an event handler for a button which instantiates an object of that class I mentioned and calls the method...
0
7416
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7676
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7442
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7776
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5347
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4965
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3456
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1905
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.