Geeks With Blogs
Andrew Siemer's Blog Enterprise Web Applications, ASP.NET MVC, C#, SQL Server, Architecture, & Writing
Its always the little things in life!  This was pretty easy...once I found it that is.

this.Form.DefaultButton = this.ButtonControl.UniqueID.ToString(); Posted on Monday, November 5, 2007 4:04 PM ASP.NET , C# | Back to top


Comments on this post: Setting a default button when using master pages

# re: Setting a default button when using master pages
Requesting Gravatar...
If you place your asp:Button in an asp:Panel you can set the defaultButton property of the panel to the button you desire.

This is especially handy on pages with multiple input "forms".
Left by Jason Whitehorn on Nov 05, 2007 5:32 PM

# re: Setting a default button when using master pages
Requesting Gravatar...
But how change graphics and ser colour for the button? .. thanks
Left by Regali di Natale on Dec 15, 2007 5:54 AM

# re: Setting a default button when using master pages
Requesting Gravatar...
You can set the color of the buttons in two primary ways...using CSS/inline styles, or you can use ASP.NET themes.


Inline styles could look something like this:
/*color of the background of the button*/
background-color:#ff0000;

/*font color of the button*/
color:#ff0000;

Or you can do css something like this:
<style>
.buttonStyle
{
background-color:#ff0000;
color:#ff0000;
}
</style>
<asp:Button cssclass="buttonStyle" id="etc" runat="server" text="button"></asp:Button>

For more on themes look here: http://msdn2.microsoft.com/en-us/library/de93t31k.aspx
Left by Andrew Siemer on Dec 15, 2007 10:51 AM

# re: Setting a default button when using master pages
Requesting Gravatar...
hi thanks
its working fine
Left by Srinivas Vadluri on Aug 27, 2008 12:10 AM

# re: Setting a default button when using master pages
Requesting Gravatar...
Looking great! But one question why to use ToString() when UniqueId itself returns string!!
Left by Ajaykumar Raju on Mar 28, 2009 3:59 AM

# re: Setting a default button when using master pages
Requesting Gravatar...
I have a problem, I have one master page however the default button is in webcontrol. How set default button in this case?

thanks
Left by angelestradamx on Oct 14, 2009 5:53 PM

# re: Setting a default button when using master pages
Requesting Gravatar...
Yes, it is so easy when you know how. Thanks for this very simple solution
Left by Vaughan on May 31, 2011 11:25 PM

# re: Setting a default button when using master pages
Requesting Gravatar...
THANK YOU SO MUSH dude! It works ! I love you !
Left by sphax on Jul 29, 2011 11:06 AM

# re: Setting a default button when using master pages
Requesting Gravatar...
It provided small but important and good information.

Thanks for putting it out there on internet.
Left by Mohamed Naseeh on Dec 26, 2011 8:24 AM

Your comment:
 (will show your gravatar)


Copyright © Andrew Siemer - www.andrewsiemer.com | Powered by: GeeksWithBlogs.net