Geeks With Blogs

Tim Huffam Dotting the I and crossing the T of I.T.

For some reason some controls/tags within ASP.NET do not always get rendered/passed to the client. 

This has happened to me on a number of occasions.  It seems limited to <style> and <script> tags - but happens for both raw HTML (within the aspx designer) and dynamically created tags (eg using new HtmlGenericControl("style")...).

This is happening to controls/tags within AJAX updatepanels within, webforms and usercontrols.

Sometimes I can work around this by simply placing these controls/tags some where else within the page structure.  But the most consistent way to get around this issue is to place a non-blanking space before the tag eg:

&nbsp;<style>...

Another half-baked solution hit's the road ;-)

Update:

After some investigation, I have found a not-so-half-baked solution - for getting javascript loaded and run on a page during an AJAX postback... 

The solution is to not try and add a script tag by adding it to a control within the page - but rather use the ASP.NET AJAX ScriptManager class's RegisterStartupScript() method.  There are two overloads for this, one loads/registers the script and runs it just once (initial page load) and the other on each asynchronous postback (the latter suited my needs).

HTH
Tim

Posted on Wednesday, July 9, 2008 10:50 PM C# .NET , ASP.NET , ASP.NET AJAX , Half Baked | Back to top


Comments on this post: ASP.NET 3.5 controls not being rendered

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Tim Huffam | Powered by: GeeksWithBlogs.net