Setting a default button using Master Pages in ASP.NET
Posted by andy gaskell on May 2nd, 2006
This one’s pretty easy, but wasn’t apparent to me at first. Put this code in your Page_Load to set a default button in master pages:
this.Form.DefaultButton = this.YOUR_DEFAULT_BUTTON.UniqueID;
October 6th, 2006 at 11:15 am
nice
April 1st, 2007 at 10:41 pm
Thanks, I was looking for that! I tried to use the plain ID of the button in my child page but that wasn’t working… Hmmm.. why? Anyways, it works now :)
April 25th, 2007 at 7:03 am
Thank You
May 6th, 2007 at 12:55 pm
Hello
You are The Best!!!
Bye
October 1st, 2007 at 2:31 pm
I don’t know if you’re teh best, but you’re defiantly pickin’ up steam!
February 13th, 2008 at 4:53 pm
ur the man!
August 27th, 2008 at 1:16 am
thanks it worked in first go
September 14th, 2008 at 4:18 am
Thanx a lot…simple n best..worked in first go.
November 4th, 2008 at 6:58 am
Thank you
January 8th, 2009 at 10:15 am
Thanks Very helpful.
March 2nd, 2009 at 3:51 pm
I was just working on my codes and found out this works for non-master pages as well.
March 19th, 2009 at 7:02 am
Hey, this helped me out great. except i had to make a small change for it to fire off for me correctly
Page.Form.DefaultButton = Me.you_button_here.UniqueID
thanks for the help either way!
June 5th, 2009 at 3:59 am
Hai, Thank you very much for your help…
October 14th, 2009 at 4:39 pm
if I have a master page with WebControl and the webcontrol has the button, my question is.. how assign default button in this case?
thank
April 30th, 2010 at 3:45 am
Thanks, it works fine.
June 30th, 2010 at 1:41 pm
Very nice! =8]
May 11th, 2011 at 1:40 am
tx man.. :)