How do I use the DefaultButton setting when using Master Pages?

D

dotnetjose

Hi Folks,

My subject message pretty musch explains it. By Default the Form
definition sits at the Master Page file.

Is there a way I can access the setting from my Content Page that uses
a Master Page?

Thanks in advance.

Jose
 
K

Ken Cox - Microsoft MVP

Hi Jose,

You just need to pass the button's UniqueID to the master page page.

Here's a sample. Let us know if it helps?

Ken
Microsoft MVP [ASP.NET]


<%@ Page Language="VB" trace="true" MasterPageFile="~/MasterPage.master"
Title="Untitled Page" %>

<script runat="server">

Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
Page.Master.Page.Form.DefaultButton = _
Button2.UniqueID
End Sub


Protected Sub Button2_Click _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
Button2.Text = "My unique ID is: " & _
Button2.UniqueID
End Sub
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<asp:button id="Button1" runat="server" text="Button" /><br />
<br />
<asp:button id="Button2" runat="server" text="Button"
onclick="Button2_Click" /><br />
<br />
<asp:imagebutton id="ImageButton1" runat="server"
imageurl="http://www.gc.ca/images/rollingflag.jpg" />
</asp:Content>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top