By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,612 Members | 1,632 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,612 IT Pros & Developers. It's quick & easy.

Update Panel not updating DOM

P: n/a
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.RegisterStartupScript 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
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

I cannot reproduce this problem. My test code:

Aspx:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Change
Control"
onclick="Button1_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.RegisterStartupScript(this.UpdatePan el1,
typeof(UpdatePanel), "allen"," <script type='text/javascript'>
alert(document.getElementById('" +
this.Label1.ClientID + "').tagName)</script>", false);

}
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox t=new TextBox();
this.Panel1.Controls.Clear();
this.Panel1.Controls.Add(t);
t.ID = "TextBox1";
ScriptManager.RegisterStartupScript(this.UpdatePan el1,
typeof(UpdatePanel), "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****@microsoft.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/5lXEfiiTgmq62x94GasSw==
| 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**********************************@microsoft.co m>
| 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.public.dotnet.general
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.general:23096
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| 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.RegisterStartupScript 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

P: n/a
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:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Change
Control"
onclick="Button1_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.RegisterStartupScript(this.UpdatePan el1,
typeof(UpdatePanel), "allen"," <script type='text/javascript'>
alert(document.getElementById('" +
this.Label1.ClientID + "').tagName)</script>", false);

}
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox t=new TextBox();
this.Panel1.Controls.Clear();
this.Panel1.Controls.Add(t);
t.ID = "TextBox1";
ScriptManager.RegisterStartupScript(this.UpdatePan el1,
typeof(UpdatePanel), "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****@microsoft.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/5lXEfiiTgmq62x94GasSw==
| 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**********************************@microsoft.co m>
| 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.public.dotnet.general
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.general:23096
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| 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.RegisterStartupScript 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 discussion thread is closed

Replies have been disabled for this discussion.