![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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? |
My System Specs![]() |
| | #2 (permalink) |
| | 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.UpdatePanel1, 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.UpdatePanel1, 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@xxxxxx. ================================================== 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@xxxxxx> | Subject: Update Panel not updating DOM | Date: Fri, 10 Oct 2008 02:03:01 -0700 | Lines: 20 | Message-ID: <504F0A04-7B8D-4DFD-8B7F-DB9A81956CE0@xxxxxx> | 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? | |
My System Specs![]() |
| | #3 (permalink) |
| | 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.UpdatePanel1, > 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.UpdatePanel1, > 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@xxxxxx. > > ================================================== > 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@xxxxxx> > | Subject: Update Panel not updating DOM > | Date: Fri, 10 Oct 2008 02:03:01 -0700 > | Lines: 20 > | Message-ID: <504F0A04-7B8D-4DFD-8B7F-DB9A81956CE0@xxxxxx> > | 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? > | > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Cant open Control Panel run windows update defender update | Vista performance & maintenance | |||
| Windows update... Not updating!!! | Vista security | |||
| Re: Updating hardware drivers through Windows Update | Vista hardware & devices | |||
| Updating Graphics Card Problems (I'd Like to Uninstall the Update) | Vista hardware & devices | |||
| Control panel no longer opening / No access to Security-Updating | Vista General | |||