Hello John,
From your description, you have some TextBox and Button controls in a
concrete page(apply a certain master page) and you're wondering how to set
the entire page form's "DefaultFoc us" and "DefaultBut ton" as the certain
Textbox and Button in content page, correct?
Based on my research, if you want to set "DefaultBut ton" and "DefaultFoc us"
of Htmlform in master page case, you need to use code to do it
programmaticall y. Also, the value you specified for the
HtmlForm.Defaul tButton and HtmlForm.Defaul tFocus are also different from
normal scenario. here is a blog article mentioned this(in the comments)
#Default Focus, Buttons and Validation Errors with ASP.NET 2.0
http://weblogs.asp.net/scottgu/archi...04/421647.aspx
I have tested on my local environment, and here is what you need to do in
content page:
** use control.UniqueI D for HtmlForm.Defaul tButton
** use control.ClientI D for HtmlForm.Defaul tFocus
here is the complete code of the test content page:
========content aspx==========
<%@ Page Language="C#" MasterPageFile= "~/masters/site.master"
AutoEventWireup ="true" CodeFile="concr etepage1.aspx.c s"
Inherits="concr ete_concretepag e1" "%>
<asp:Content ID="Content1" ContentPlaceHol derID="ContentP laceHolder1"
Runat="Server">
<asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button 1_Click"
Text="Button" /><br />
<hr />
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"
BorderStyle="so lid" BorderColor="bl ack">
<asp:TextBox ID="TextBox2" runat="server"> </asp:TextBox>
<asp:Button ID="Button2" runat="server" OnClick="Button 2_Click"
Text="Button" />
<asp:ImageButto n ID="ImageButton 1" runat="server"
ImageUrl="http://static.asp.net/asp.net/images/MicrosoftASPNET .gif"
OnClick="ImageB utton1_Click" /></asp:Panel>
</asp:Content>
=========conten t codebehind===== ===
public partial class concrete_concre tepage1 : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
Page.Form.Defau ltButton = ImageButton1.Un iqueID;
Page.Form.Defau ltFocus = TextBox2.Client ID;
}
protected void Button1_Click(o bject sender, EventArgs e)
{
Response.Write( "Button1_Click. .........");
}
protected void Button2_Click(o bject sender, EventArgs e)
{
Response.Write( "Button2_Click. .........");
}
protected void ImageButton1_Cl ick(object sender, ImageClickEvent Args e)
{
Response.Write( "ImageButton1_C lick.........." );
}
}
=============== =============== =============
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.