<?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: Input -&gt; Button, workaround</title><link>http://forums.asp.net/thread/3274769.aspx</link><pubDate>Sat, 04 Jul 2009 15:21:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274769</guid><dc:creator>bissoi</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274769.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=3274769</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Thanks rtpHarry for this link. very useful. i guess most the time you don&amp;#39;t care about the button value as much as the other editable fields. textAreas, textboxes, etc... but good to know about this issue in IE.&lt;/p&gt;</description></item><item><title>Re: Input -&gt; Button, workaround</title><link>http://forums.asp.net/thread/3268849.aspx</link><pubDate>Wed, 01 Jul 2009 12:24:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3268849</guid><dc:creator>rtpHarry</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3268849.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=3268849</wfw:commentRss><description>&lt;p&gt;Thats some nice clean code!&lt;/p&gt;&lt;p&gt;One thing to be wary of that there are compatibility issues with the &amp;lt;button&amp;gt; tag, IE, and forms:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.sitehatchery.com/blog/index.php/html-button-tag-and-ie-compatibility"&gt;http://www.sitehatchery.com/blog/index.php/html-button-tag-and-ie-compatibility&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Input -&gt; Button, workaround</title><link>http://forums.asp.net/thread/3268828.aspx</link><pubDate>Wed, 01 Jul 2009 12:17:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3268828</guid><dc:creator>bissoi</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3268828.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=19&amp;PostID=3268828</wfw:commentRss><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Yesterday, I had a little chat with a friend who is in love with Mootools &amp;nbsp;(the JavaScript Library, &lt;a href="http://www.mootools.net/"&gt;www.mootools.net&lt;/a&gt;). he is a web UI and client side scripting expert, currently he is working on a project that backed on ASP.NET serverside. &lt;/p&gt;
&lt;p&gt;in most of mootools validation&amp;nbsp;classes and plugins, that he used to write and use, are dealing with Submit buttons or Normal Buttons and relaying on the &amp;lt;Button&amp;gt; html tag more than the &amp;lt;input type=&amp;quot;submit&amp;quot;&amp;gt; or the &amp;lt;input&amp;nbsp; type=&amp;quot;button&amp;quot;&amp;gt; tags.&amp;nbsp; so he was facing a problem when he push the interface to the ASP.NET kitchen, where the programmer there has to replace the client side&amp;lt;button&amp;gt; with &amp;lt;asp:button /&amp;gt; server side control which by default will render its output as &amp;lt;input&amp;gt; tag. &lt;/p&gt;
&lt;p&gt;so i thought to send him this little class control that inherits the same asp:button, and render its output as &amp;lt;button&amp;gt; tag to serve his mootooling scripts. in beside of that i did add a custom client ID property, that he override the one that ASP.NET assign to the control specially if it was nested inside other user controls. and that would solve a lot of the issues that he was facing in using mootools/ASP.NET marriage.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;public class mootoolsbtn : Button
{
    private string _myClientID;

    public string myClientID
    {
        get
        {
            _myClientID = (string)this.ViewState[&amp;quot;clientID&amp;quot;];
            return (_myClientID == null) ? &amp;quot;&amp;quot; : _myClientID;
        }
        set
        {
            this.ViewState[&amp;quot;clientID&amp;quot;] = value;
        }
    }
    public override void RenderBeginTag(HtmlTextWriter writer)
    {

        AddAttributesToRender(writer);        
        writer.RenderBeginTag(&amp;quot;button&amp;quot;);

    }
    protected override void RenderContents(HtmlTextWriter writer)
    {
        writer.Write(base.Text);        
        base.RenderContents(writer);
    }
    protected override void AddAttributesToRender(HtmlTextWriter writer)
    {
        base.Attributes.Remove(&amp;quot;id&amp;quot;);
        writer.AddAttribute(&amp;quot;id&amp;quot;, this.myClientID);
        base.AddAttributesToRender(writer);
    }
}&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;and in any webform page he can register this control and use it instead of the asp:button.&lt;/p&gt;&lt;pre class="xhtml" name="code"&gt;&amp;lt;myC:mootoolsbtn OnClick=&amp;quot;myOButton_Click&amp;quot; OnClientClick=&amp;quot;window.alert(&amp;#39;Hello there&amp;#39; + this.id); return true;&amp;quot; runat=&amp;quot;server&amp;quot; myClientID=&amp;quot;FakeClientID&amp;quot; ID=&amp;quot;myBTN&amp;quot; Text=&amp;quot;Click Me&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;p&gt;and it will be renderd out to the client as :&lt;/p&gt;&lt;pre class="xhtml" name="code"&gt;&amp;lt;button id=&amp;quot;FakeClientID&amp;quot; type=&amp;quot;submit&amp;quot; name=&amp;quot;myBTN&amp;quot; value=&amp;quot;Click Me&amp;quot; onclick=&amp;quot;window.alert(&amp;#39;Hello there&amp;#39; + this.id); return true;&amp;quot; id=&amp;quot;myBTN&amp;quot;&amp;gt;Click Me&amp;lt;/button&amp;gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;and clicking on it will call the javascript code&amp;nbsp;beside it will fire the&amp;nbsp;server side void. myOButton_click.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;hope that can help&amp;nbsp;and be useful for any one in love with mootools or any other&amp;nbsp;JS library.&lt;/p&gt;
&lt;p&gt;cheers,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>