Showing posts with label defaultfocus. Show all posts
Showing posts with label defaultfocus. Show all posts

Wednesday, March 21, 2012

defaultbutton, defaultfocus and UpdatePanel

Looks like defaultbutton and defaultfocus properties of the asp.net <form> do not work with UpdatePanel. Is there a workaround?

<

scriptrunat="server">protectedvoid Button1_Click(object sender,EventArgs e)

{

Label1.Text =

"You clicked the button1";

form1.DefaultButton =

"Button2";

}

protectedvoid Button2_Click(object sender,EventArgs e)

{

Label1.Text =

"You clicked the button2";

}

</

script>

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>Untitled Page</title>

</

head>

<

body><atlas:ScriptManagerID="sm1"runat="server"EnablePartialRendering="true"/><formid="form1"runat="server"defaultbutton="Button1"defaultfocus="TextBox1"><atlas:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><asp:ButtonID="Button1"runat="server"OnClick="Button1_Click"Text="Button"/><asp:ButtonID="Button2"runat="server"OnClick="Button2_Click"Text="Button"/><asp:LabelID="Label1"runat="server"Text=""></asp:Label></ContentTemplate></atlas:UpdatePanel></form>

</

body>

</

html>

hello.

the only i've used with success was to handle the propertychanged event of the pagerequestmanager and check for the _inPostBack...if you search this forum, you'll see a similar thread with 15 to 20 posts that talks about this issue.


I am having the same problem and i am not able to locate the article with the search request that you have mentioned.

Can you please provide it to me please. This is the last hurdle for me before the release :(

Thanks a lot in advance.

Try this. It solved my problem

protectedvoid Page_Load(object sender,EventArgs e)

{

Page.Form.DefaultFocus = nameTextBox.ClientID;

Page.Form.DefaultButton = submitButton.UniqueID;

}

DefaultButton and DefaultFocus

Hi

I have a code, when i use DefaultButton and DefaultFocus.

When i put UpdatePanel to the Page, DefaultButton and DefaultFocus work only on first load of page. After callback it is dosn't work. Anybody know where is the problem?

Btw. I use MasterPage in this code then i set DefaultButton and DefaultFocus in PageLoad

Page.Form.DefaultButton = this.Button1.UniqueId;

Hi,

I also faced the same issue. I think the asp.net provided default button has some issue regarding this

I worked with BinaryIntellect DefaultButton server controls which works as expected. You may try it from here: http://www.binaryintellect.com/products

Cheers,
Murugan.G

I encounted the same problem before, Finally, I put me.textbox1.focus in Page_Load, that OK, you may try it.