<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx</link><description>So you want to build a custom asp.net control. And you want to have some whiz bang, complex script that goes with it. Well, there are a few methods on System.Web.UI.Page that help you emit script into the right places, but the docs on these methods don</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#5649727</link><pubDate>Fri, 25 Jan 2008 11:28:20 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:5649727</guid><dc:creator>retrwetwe</dc:creator><author>retrwetwe</author><description>&lt;p&gt;ertgwetgf erw tfwertg retg rewgw ergwer tg wregw&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=5649727" width="1" height="1"&gt;</description></item><item><title>javascript objects in javascript arrays - oneliner :)</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#413517</link><pubDate>Fri, 17 Jun 2005 13:28:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:413517</guid><dc:creator>TrackBack</dc:creator><author>TrackBack</author><description>&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=413517" width="1" height="1"&gt;</description></item><item><title>re: How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#168242</link><pubDate>Tue, 29 Jun 2004 01:24:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:168242</guid><dc:creator>Ryan Eaves</dc:creator><author>Ryan Eaves</author><description>One caveat to the StreamReader line you are using to read the script from the .js file is that it won't work as written if you are using namespaces below the root namespace for your assembly. Embedded Resources are located in the root namespace for the assembly.&lt;br&gt;&lt;br&gt;If your control is named as follows: myAssembly.myWebControls.FooControl, then passing typeof(FooControl) to GetManifestResourceStream() will cause it to look in myAssembly.myWebControls for the embedded resource. However, it is not in myAssembly.myWebControls, it is in myAssembly.&lt;br&gt;&lt;br&gt;The solution is to provide the fully qualified name for the resource, which is just as easy. Simply add the assembly name to the resource name, instead of passing the type. Like this:&lt;br&gt;&lt;br&gt;using (System.IO.StreamReader reader = new System.IO.StreamReader(typeof(FooControl).Assembly.GetManifestResourceStream(typeof(FooControl).Assembly.GetName().Name + &amp;quot;.FooControl.js&amp;quot;)))&lt;br&gt;&lt;br&gt;Rather than deriving the namespace from the type you have passed, GetManifestResourceStream will just use the full name that you passed instead, and it will work regardless of what namespace the control is in.&lt;br&gt;&lt;br&gt;--&lt;br&gt;Ryan Eaves&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=168242" width="1" height="1"&gt;</description></item><item><title>re: How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#156219</link><pubDate>Tue, 15 Jun 2004 16:51:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:156219</guid><dc:creator>Terrence Chan</dc:creator><author>Terrence Chan</author><description> use the below code to set focus in an aspx(System.Web.UI.page). &lt;br&gt;&lt;br&gt;Now I covert the page into a web control ascx. The RegisterStartupScript method is not available in System.Web.UI.UserControl. &lt;br&gt;&lt;br&gt;How can I set focus in web control? &lt;br&gt;&lt;br&gt;Thanks, &lt;br&gt;Terrence &lt;br&gt;&lt;br&gt;&lt;br&gt;Private Sub SetFocus(ByVal CtrlName As String) &lt;br&gt;Dim strBuilder As StringBuilder = New StringBuilder &lt;br&gt;strBuilder.Append(&amp;quot;&amp;lt;script language = 'javascript'&amp;gt;&amp;quot;) &lt;br&gt;strBuilder.Append(&amp;quot;var obj;&amp;quot;) &lt;br&gt;strBuilder.Append(&amp;quot;obj = document.getElementById('&amp;quot; &amp;amp; CtrlName &amp;amp; &amp;quot;');&amp;quot;) &lt;br&gt;strBuilder.Append(&amp;quot;if (obj){&amp;quot;) &lt;br&gt;strBuilder.Append(&amp;quot;document.getElementById('&amp;quot; &amp;amp; CtrlName &amp;amp; &amp;quot;').focus();&amp;quot;) &lt;br&gt;strBuilder.Append(&amp;quot;}&amp;quot;) &lt;br&gt;strBuilder.Append(&amp;quot;&amp;lt;/script&amp;gt;&amp;quot;) &lt;br&gt;RegisterStartupScript(&amp;quot;focus&amp;quot;, strBuilder.ToString) &lt;br&gt;End Sub&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=156219" width="1" height="1"&gt;</description></item><item><title>re: How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#112551</link><pubDate>Tue, 13 Apr 2004 20:26:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:112551</guid><dc:creator>Eric Newton</dc:creator><author>Eric Newton</author><description>Whidbey's framework allows for &amp;quot;WebResources&amp;quot; whereas the JS files and possibly GIFs for Icons for controls can be embedded into the DLL and exposed as resources that aspnet_isapi will link to.&lt;br&gt;&lt;br&gt;I just know I can't wait for Whidbey, but apparently its been delayed!  arg!&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=112551" width="1" height="1"&gt;</description></item><item><title>re: How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#95163</link><pubDate>Wed, 24 Mar 2004 11:38:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:95163</guid><dc:creator>the kid</dc:creator><author>the kid</author><description> var myFooControl = document.getElementById( fooControlProperties.ID );&lt;br&gt;&lt;br&gt;Returns Null for myFooControl. (the ClientID is not there)&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=95163" width="1" height="1"&gt;</description></item><item><title>re: How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#84415</link><pubDate>Fri, 05 Mar 2004 12:51:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:84415</guid><dc:creator>treytry</dc:creator><author>treytry</author><description>dfghd&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=84415" width="1" height="1"&gt;</description></item><item><title>re: How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#84414</link><pubDate>Fri, 05 Mar 2004 12:50:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:84414</guid><dc:creator>treytry</dc:creator><author>treytry</author><description>dfghd&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=84414" width="1" height="1"&gt;</description></item><item><title>re: How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#34442</link><pubDate>Wed, 29 Oct 2003 16:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:34442</guid><dc:creator>Steve Laing</dc:creator><author>Steve Laing</author><description>hehe - have a look in mozilla!&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=34442" width="1" height="1"&gt;</description></item><item><title>re: How to use clientscript in custom controls</title><link>http://weblogs.asp.net/asmith/pages/25465.aspx#25603</link><pubDate>Wed, 27 Aug 2003 22:58:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:25603</guid><dc:creator>Andy Smith</dc:creator><author>Andy Smith</author><description>I like it. I may change my recommendation after looking into it.&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=25603" width="1" height="1"&gt;</description></item></channel></rss>