<?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>Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx</link><description>This entry was posted in 2003. There are better ways to do this with the newest version of ASP.net! Hitting the enter key in a TextBox can sometimes have undesired effects like the wrong submit Button being “clicked“. The method described below allows</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#7138187</link><pubDate>Wed, 01 Jul 2009 19:52:56 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7138187</guid><dc:creator>Jazitron</dc:creator><author>Jazitron</author><description>&lt;p&gt;Al fin encontre un ejemplo adecuado a mis necesidades, con este si me funciono, ya que tenia otro evento en esa caja de texto y no me funcionaba.&lt;/p&gt;
&lt;p&gt;Gracias.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7138187" width="1" height="1"&gt;</description></item><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#7094085</link><pubDate>Thu, 21 May 2009 12:20:19 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7094085</guid><dc:creator>Dimitri</dc:creator><author>Dimitri</author><description>&lt;p&gt;This is quite an elegant solution.&lt;/p&gt;
&lt;p&gt;However, if i recall correctly, not all browsers support calling click() on a button (or was that for hyperlinks only?). Either way, you might want to do something along the lines of &lt;/p&gt;
&lt;p&gt;if( bt.click) &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;bt.click();&lt;/p&gt;
&lt;p&gt;else if(bt.onclick)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;t.onclick();&lt;/p&gt;
&lt;p&gt;Also, as an alternative, if the number of &amp;quot;submitting textboxes&amp;quot; is few, you might want to consider setting AutoPostBack=true on the textbox and also setting OnTextChanged handler to the same eventhandler as your button control. That way you can still distinguish between a button click and a textbox enter on the server side (by checking the sender&amp;#39;s type).&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7094085" width="1" height="1"&gt;</description></item><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#6999233</link><pubDate>Wed, 25 Mar 2009 10:19:08 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6999233</guid><dc:creator>Raj</dc:creator><author>Raj</author><description>&lt;p&gt;Thanks a lot, thats helped me lot.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6999233" width="1" height="1"&gt;</description></item><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#6952307</link><pubDate>Tue, 10 Mar 2009 11:47:16 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6952307</guid><dc:creator>Renjith.K.C</dc:creator><author>Renjith.K.C</author><description>&lt;p&gt;Simply the best. Thanks a lot......&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6952307" width="1" height="1"&gt;</description></item><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#6939466</link><pubDate>Thu, 05 Mar 2009 20:19:11 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6939466</guid><dc:creator>DT</dc:creator><author>DT</author><description>&lt;p&gt;This is a bunch of incomprehensible garbage! This stuff works only if you&amp;#39;re already a very fluent programmer. I&amp;#39;m writing my first website in very clean, plain, basic html and css. None of this stuff makes sense! Why can&amp;#39;t you provide a very simple, step by step method that uses an actual example? I don&amp;#39;t know whether I&amp;#39;m supposed to replace these little codes such as &amp;quot;buttonid&amp;quot; with the name of my button or leave it as such, etc. It&amp;#39;s too complicated for a beginner!&lt;/p&gt;
&lt;p&gt;dt263@yahoo.com&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6939466" width="1" height="1"&gt;</description></item><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#6909888</link><pubDate>Mon, 16 Feb 2009 15:46:55 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6909888</guid><dc:creator>Henry</dc:creator><author>Henry</author><description>&lt;p&gt;Excelente. &lt;/p&gt;
&lt;p&gt;Saludos desde Peru.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6909888" width="1" height="1"&gt;</description></item><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#6810526</link><pubDate>Thu, 01 Jan 2009 11:49:41 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6810526</guid><dc:creator>Muhammad Tabish</dc:creator><author>Muhammad Tabish</author><description>&lt;p&gt;really nice work..&lt;/p&gt;
&lt;p&gt;thankss alot sir.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6810526" width="1" height="1"&gt;</description></item><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#6809730</link><pubDate>Wed, 31 Dec 2008 08:17:11 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6809730</guid><dc:creator>sangam</dc:creator><author>sangam</author><description>&lt;p&gt;Excellent. In fact is searched in asp.net forums and could only witness the solution that keep the textbox and button in a panel and set the default button. But this one is far better in speed and simplicity also. Thank you again!&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6809730" width="1" height="1"&gt;</description></item><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#6718288</link><pubDate>Mon, 03 Nov 2008 19:19:42 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6718288</guid><dc:creator>Rajesh</dc:creator><author>Rajesh</author><description>&lt;p&gt;Fantastic piece of code...thanks a lot &lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6718288" width="1" height="1"&gt;</description></item><item><title>re: Setting the default Button for a TextBox in ASP.NET</title><link>http://weblogs.asp.net/rajbk/archive/2003/12/11/setting-the-default-button-for-a-textbox-in-asp-net.aspx#6697517</link><pubDate>Wed, 22 Oct 2008 07:21:28 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6697517</guid><dc:creator>asp .net user</dc:creator><author>asp .net user</author><description>&lt;p&gt;nice work it help me alot &amp;nbsp;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6697517" width="1" height="1"&gt;</description></item></channel></rss>