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?
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.
Tualatin
Member
131 Points
172 Posts
Content page - setting the accept button
May 12, 2010 08:07 PM|LINK
Hi All!
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!
John
Jalpesh P. V...
Contributor
2056 Points
333 Posts
Re: Content page - setting the accept button
May 13, 2010 06:20 AM|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.
Cheers,
Microsoft MVP(Visual C#),
www.dotnetjalps.com
Mark as answer if my anwers helps you
Dave Sussman
All-Star
37716 Points
5005 Posts
ASPInsiders
MVP
Re: Content page - setting the accept button
May 13, 2010 10:07 AM|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>
<asp:Panel id="ContentArea" runat="server">
<asp:ContentPlaceHolder ...>
</asp:ContentPlaceHolder>
</asp:Panel>
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.