Last post May 13, 2010 11:07 AM by Dave Sussman
May 12, 2010 09:07 PM|Tualatin|LINK
I wish to set the accept button for each of my content pages. My Master Page login button is set as the accept button somehow. This is fine for the home page, but not the majority of the other 40 pages.
All of my website pages are content pages and they are linked to the master page. They don't have forms, just contentplaceholder tags.
Does anyone know if there is a way to programaticaly set the accept button in the code behind of a content page?
Thanks in advance for your assistance!
May 13, 2010 07:20 AM|Jalpesh P. Vadgama|LINK
What do you mean by accept button. If you are looking for default button then you can set it with default button.
Another way of doing this crate mypage class inhering page class which will have by default button and your pages will have this button.
May 13, 2010 11:07 AM|Dave Sussman|LINK
The simplest way to do this is to wrap things in Panels and set the DefaultButton on the Panel. For example, your master page could have:
<asp:Panel id="LoginArea" runat="server" DefaultButton="LoginButton">
your login code here
<asp:Panel id="ContentArea" runat="server">
In your code behind for the pages you'd have to do this (probably in Page_Load):
(Master.FindControl("ContentArea") as Panel).DefaultButton = "ID of button goes here";
or in VB
CType(Master.FindControl("ContentArea"), Panel).DefaultButton = "Id of button goes here"
You may not need the panel around the login area if you put one around the content, and in fact if you're using the standard Login control, then you probably can't because it encapsulates the button.