473,414 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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

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

Mar 19 '06 #1
2 3717
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>

<do********@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
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

Mar 19 '06 #2
Thanks for the quick response. Works great.. :)

Mar 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: mablejune | last post by:
HtmlForm frm = (HtmlForm)Master.FindControl("formMain"); frm.DefaultButton = "btnSubmit"; txtCall.Focus(); Running this code produces the following error message: The DefaultButton of...
0
by: Evert Wiesenekker | last post by:
I have a mail page with a send button containing three validators (2 required val. and 1 expression val.). The masterpage contains 3 imagebuttons. Now when I press enter the first time the...
1
by: Amit Bansal \(MCT, MCSD.NET\) | last post by:
the msdn documentation says that if we can do application level binding by specifying the masterpagefile attribute in web.config, so that all the pages in the application are bound to a master...
3
by: John Mott | last post by:
Hi All, I'm trying to set the defaultbutton for a form to a button contained in a step template for a wizard control. This is the code in PreRender: switch (myWizard.ActiveStep.StepType) {...
2
by: =?Utf-8?B?QmlnSm9obg==?= | last post by:
We can set the default button and focus field in ASP.Net 2.0 on the Form tag. My form tag is in the Master page, but the controls are in containers. I read through a few articles which did not...
4
by: Tim Mackey | last post by:
hi, asp.net 2. can anyone explain why this code does not work in firefox (2.0.0.1), but does work in IE 7. if you hit enter after typing something into the textbox, it should fire the Submit...
3
by: William Youngman | last post by:
I am on a team that is developing a proposal generation web application and we are using a custom base page (ProGenBase.cs) located in the app_code directory and all of the app's web pages inherit...
0
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I have a MasterPage but on each particular page that uses it, I need to be able to set the DefaultButton for the Form for that page. From the .cs file of my ASPX page, I have tried: -...
0
by: dihola | last post by:
Hi all, I am developing 2 websites (A and B) that share a lot of pages and classes, and I wonder if I am doing it the right way. I have extracted the common classes and created master pages for all...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.