Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 10th, 2008, 10:15 AM
=?Utf-8?B?TUNN?=
Guest
 
Posts: n/a
Default 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.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?
  #2  
Old October 13th, 2008, 08:35 AM
Allen Chen [MSFT]
Guest
 
Posts: n/a
Default RE: Update Panel not updating DOM

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:
msdnmg@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?= <MCM@newsgroup.nospam>
| Subject: Update Panel not updating DOM
| Date: Fri, 10 Oct 2008 02:03:01 -0700
| Lines: 20
| Message-ID: <504F0A04-7B8D-4DFD-8B7F-DB9A81956CE0@microsoft.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.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?
|

  #3  
Old October 13th, 2008, 12:25 PM
=?Utf-8?B?TUNN?=
Guest
 
Posts: n/a
Default RE: Update Panel not updating DOM

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:
Quote:
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:
msdnmg@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?= <MCM@newsgroup.nospam>
| Subject: Update Panel not updating DOM
| Date: Fri, 10 Oct 2008 02:03:01 -0700
| Lines: 20
| Message-ID: <504F0A04-7B8D-4DFD-8B7F-DB9A81956CE0@microsoft.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.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?
|
>
>
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles