<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.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>Custom Server Controls</title><link>http://forums.asp.net/19.aspx</link><description>All about building ASP.NET server controls. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=12&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1445883.aspx</link><pubDate>Sun, 29 Oct 2006 23:53:10 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1445883</guid><dc:creator>Moskie</dc:creator><author>Moskie</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1445883.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1445883</wfw:commentRss><description>&lt;p&gt;Whoops, sorry, part of the text I supplied didn&amp;#39;t show up in my post. Here&amp;#39;s what I meant to say:&amp;nbsp;&lt;/p&gt;&lt;p&gt;I&amp;#39;m using the method from the blog to force the IDs to be what I want, but I&amp;#39;ve encountered another problem that I think might a be a result of using this method.&lt;/p&gt;&lt;p&gt;I&amp;#39;ve created a class that inherits from HtmlGenericControl. It overrides UniqueID and ClientID so that they both return this.ID. It also has contructors in the class that call the base class&amp;#39; constructors... and that&amp;#39;s all that I have in the class.&lt;/p&gt;&lt;p&gt;But now I&amp;#39;m getting an error when I try to view the Trace page of a page that uses objects of this type. The error is a Null Reference Exception that occurs in System.Web.Handlers.TraceHandler.CreateControlTable(DataTable datatable) +2442. I&amp;#39;m not 100% sure that using my custom class is causing the problem, but that&amp;#39;s my suspicion. &lt;/p&gt;&lt;p&gt;Can someone confirm (or refute) this for me? I&amp;#39;m thinking there&amp;#39;s something else I have to have in my class, but I&amp;#39;m not sure what that is. Any help is appreciated!&lt;/p&gt;</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1445845.aspx</link><pubDate>Sun, 29 Oct 2006 22:53:24 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1445845</guid><dc:creator>Moskie</dc:creator><author>Moskie</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1445845.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1445845</wfw:commentRss><description>I&amp;#39;m using the method&amp;nbsp;described&amp;nbsp;in&amp;nbsp;that&amp;nbsp;blog to force the IDs to be what I want, but I&amp;#39;ve encountered another problem that I think might a be a result of using this method.&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve created a class that inherits from HtmlGenericControl. It overrides UniqueID and ClientID so that they both return this.ID. It also has contructors in the class that call the base class&amp;#39; constructors... and that&amp;#39;s all that I have in the class.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Can someone confirm (or refute) this for me? I&amp;#39;m thinking there&amp;#39;s something else I have to have in my class, but I&amp;#39;m not sure what that is. Any help is appreciated!&lt;br /&gt;&lt;br /&gt;This is with .Net 2.0.&lt;br /&gt;&lt;br /&gt;</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1278098.aspx</link><pubDate>Sat, 06 May 2006 08:00:37 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1278098</guid><dc:creator>monolithx</dc:creator><author>monolithx</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1278098.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1278098</wfw:commentRss><description>Thank you both for your advice...&lt;br /&gt;</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1278085.aspx</link><pubDate>Sat, 06 May 2006 06:56:20 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1278085</guid><dc:creator>joteke</dc:creator><author>joteke</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1278085.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1278085</wfw:commentRss><description>&lt;p&gt;Like said earlier, there's no hardcoding, if one takes ClientID of server-side control and uses that to create the ID into generated script.&lt;/p&gt;
&lt;p&gt;Taking previous example&amp;nbsp; say you have TextBox on form&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&amp;lt;asp:TextBox ID="TextBox1" runat="server" /&amp;gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;You could make a script as follows&lt;/p&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;function foo()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; document.getElementById('&amp;lt;%=TextBox1.ClientID%&amp;gt;').value = "bar";&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;which would render the correct ID at client-side (client ID would change based on if control is placed inside a naming container such as a user control). Therefore creating js call is possible also in server-side code (this example was just inline script) as TextBox is programmatically 100% available there (especially ClientID in this scenario)&lt;/p&gt;</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1277785.aspx</link><pubDate>Fri, 05 May 2006 19:15:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1277785</guid><dc:creator>Ran Davidovitz</dc:creator><author>Ran Davidovitz</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1277785.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1277785</wfw:commentRss><description>Hi,&lt;br /&gt;Putting hardcoded IDs in the code is BAD and should be avoided.&lt;br /&gt;As a intermediate code you can change your javascript code from using a hardcoded ID to a predefined variable.&lt;br /&gt;So a function like this:&lt;br /&gt;&lt;br /&gt;function foo()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;textboxa.value = "bar";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Will become:&lt;br /&gt;&lt;br /&gt;function foo()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;m_Defined_Textbox.value = "bar";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;And now the only thing you need to do is to render a script that will initialize m_Defined_Textbox to the client id of the textbox.&lt;br /&gt;Hope this helps.</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1271681.aspx</link><pubDate>Sat, 29 Apr 2006 11:44:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1271681</guid><dc:creator>joteke</dc:creator><author>joteke</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1271681.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1271681</wfw:commentRss><description>&lt;p&gt;That is the "official" way getting the ID.&lt;/p&gt;
&lt;p&gt;Why cannot you create only those&amp;nbsp;function calls(s) which just take the ID in. That way, you wouldn't need to output&amp;nbsp;all but only&amp;nbsp;but those function calls&amp;nbsp;from the control. &lt;/p&gt;
&lt;p&gt;E.g put static part of the script into separate js file (or resource as was in the link I gave), and only make&amp;nbsp;the calls into those functions which require the ID (generally speaking set the ID). &lt;/p&gt;
&lt;p&gt;If you expect your control to exist only once on Page, you certainly could output just a js variable where the client&amp;nbsp;ID would be&amp;nbsp;given&amp;nbsp;(script library would use that then)&lt;/p&gt;</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1271676.aspx</link><pubDate>Sat, 29 Apr 2006 11:33:27 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1271676</guid><dc:creator>monolithx</dc:creator><author>monolithx</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1271676.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1271676</wfw:commentRss><description>Crossposted :-)&lt;br /&gt;
Ok, I've seen, but using CLIENTID property would imply creating
javascript in C# code line by line which is what I want to avoid. I
wan't resourced or at least external .js file...&lt;br /&gt;
&lt;br /&gt;</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1271674.aspx</link><pubDate>Sat, 29 Apr 2006 11:25:08 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1271674</guid><dc:creator>joteke</dc:creator><author>joteke</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1271674.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1271674</wfw:commentRss><description>See my previous reply. :-)</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1271673.aspx</link><pubDate>Sat, 29 Apr 2006 11:24:18 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1271673</guid><dc:creator>monolithx</dc:creator><author>monolithx</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1271673.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1271673</wfw:commentRss><description>And yes, rewritting control aka overriding crossed my mind, but as on
the link you gave author found out, this would create other problems.&lt;br /&gt;
I was wondering if there is a more elegant, official way to pass
somehow real ids to javascript functions without dynamic script
generation in cb.&lt;br /&gt;
&lt;br /&gt;</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1271672.aspx</link><pubDate>Sat, 29 Apr 2006 11:23:58 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1271672</guid><dc:creator>joteke</dc:creator><author>joteke</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1271672.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1271672</wfw:commentRss><description>&lt;p&gt;Ah,&lt;/p&gt;
&lt;p&gt;you can always get the ASP.NET generated clientid by taking it from control's ClientID property. Does that help?&lt;/p&gt;</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1271670.aspx</link><pubDate>Sat, 29 Apr 2006 11:17:56 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1271670</guid><dc:creator>monolithx</dc:creator><author>monolithx</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1271670.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1271670</wfw:commentRss><description>OK, ty, I will try to explain a bit more, sorry.&lt;br /&gt;
&lt;br /&gt;
I have a text editor made with javascript (BBcode able etc).&lt;br /&gt;
My js is held in editor.js and consists of functions that operate on
editor elements which are textarea, buttons, images, editboxes, divs...&lt;br /&gt;
So, to be able to use js for that I'm using unique names (ids) for me
editor elements and/or divs; like "editarea" for textarea, "boldButt"
for bold button control, etc.&lt;br /&gt;
In PHP, which I used to use, there would be no problem as I would
simply include my .js up in the head and my editor control (actually a
heap of controls editor is made of) and all would work fine.&lt;br /&gt;
In ASP.NET however, I'm facinga&amp;nbsp; problem that being ASP.NET plays
a wiseguy ^^ and renames my clientids to something of a nested naming
style to ensure unique names.&lt;br /&gt;
Well, as I can't know how deep into a page my editor will be nested (as
control should be usable everyhwere), I can't setup my js script with
correct client ids so my scripts don't work as usually instead of just
"boldButt" my button is, in final html, named
"$ctrl00$kfdjdvk3gbjdsg$hdgoudboldButt"...&lt;br /&gt;
&lt;br /&gt;
I've seen javascript can be built line by line in codebehind, but for a
500-1000 lines js script, that can become a little bit tedious and
messy least to say...&lt;br /&gt;
&lt;br /&gt;
So, I need a way to make my scripts work... :-)&lt;br /&gt;
&lt;br /&gt;</description></item><item><title>Re: How to force...</title><link>http://forums.asp.net/thread/1271655.aspx</link><pubDate>Sat, 29 Apr 2006 10:20:23 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1271655</guid><dc:creator>joteke</dc:creator><author>joteke</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1271655.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1271655</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;a href="http://west-wind.com/weblog/posts/4605.aspx"&gt;http://west-wind.com/weblog/posts/4605.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What do you mean with including whole script at once? If you have&amp;nbsp; a script you can throw it out with &lt;font face="Courier New"&gt;Page.ClientScript.RegisterClientScriptBlock. &lt;font face="Times New Roman"&gt;If you have it as external file then using&lt;/font&gt; RegisterClientScriptInclude (or RegisterClientScriptResource if its available as a web resource)&amp;nbsp;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;About the resource way: &lt;a href="http://west-wind.com/weblog/posts/4310.aspx"&gt;http://west-wind.com/weblog/posts/4310.aspx&lt;/a&gt;&lt;/p&gt;</description></item><item><title>How to force...</title><link>http://forums.asp.net/thread/1270023.aspx</link><pubDate>Thu, 27 Apr 2006 15:17:41 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1270023</guid><dc:creator>monolithx</dc:creator><author>monolithx</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1270023.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=1270023</wfw:commentRss><description>... clientid?&lt;br /&gt;
I have problems with javascript because asp.net messes with my clientids...&lt;br /&gt;
Also, is it possible to include whole script at once and not build it line by line?&lt;br /&gt;
&lt;br /&gt;</description></item></channel></rss>