473,326 Members | 2,588 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,326 software developers and data experts.

DefaultButton What's wrong with this code?

HtmlForm frm = (HtmlForm)Master.FindControl("formMain");
frm.DefaultButton = "btnSubmit";
txtCall.Focus();

Running this code produces the following error message:

The DefaultButton of 'formMain' must be the ID of a control of type
IButtonControl.

btnSubmit is a System.Web.UI.WebControls.Button which implements
IButtonControl.

Is this a bug?
Dec 14 '05 #1
9 1506
You could use this free control to solve the problem.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here are a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/20...200406so_f.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
<ma*******@otismukinfus.com> wrote in message
news:j1********************************@4ax.com...
HtmlForm frm = (HtmlForm)Master.FindControl("formMain");
frm.DefaultButton = "btnSubmit";
txtCall.Focus();

Running this code produces the following error message:

The DefaultButton of 'formMain' must be the ID of a control of type
IButtonControl.

btnSubmit is a System.Web.UI.WebControls.Button which implements
IButtonControl.

Is this a bug?

Dec 14 '05 #2
On Tue, 13 Dec 2005 21:00:49 -0800, "Steve C. Orr [MVP, MCSD]"
<St***@Orr.net> wrote:

Thank you Steve, but neither of the links you sent answers my question
about why the code doesn't work. The code is from ASP.NET 2.0 and the
Default button property is a new property of the form object. My
question is why does this not work as it should.
You could use this free control to solve the problem.
http://www.metabuilders.com/tools/DefaultButtons.aspx

And here are a couple good articles on the subject:
http://www.allasp.net/enterkey.aspx
http://www.aspnetpro.com/features/20...200406so_f.asp

Dec 14 '05 #3
Try assigning DefaultButton to the ClientID of the button.

Something like this:
HtmlForm frm = (HtmlForm)Master.FindControl("formMain");
IButtonControlbtn = (IButtonControl)Master.FindControl("btnSubmit");
frm.DefaultButton = btn.ClientID;
txtCall.Focus();

Joshua Flanagan
http://flimflan.com/blog
Dec 15 '05 #4
On Wed, 14 Dec 2005 18:04:53 -0600, Joshua Flanagan <jo**@msnews.com>
wrote:

Thank you Joshua. I'll do that.
Try assigning DefaultButton to the ClientID of the button.

Something like this:
HtmlForm frm = (HtmlForm)Master.FindControl("formMain");
IButtonControlbtn = (IButtonControl)Master.FindControl("btnSubmit");
frm.DefaultButton = btn.ClientID;
txtCall.Focus();

Joshua Flanagan
http://flimflan.com/blog

Dec 15 '05 #5
On Wed, 14 Dec 2005 18:04:53 -0600, Joshua Flanagan <jo**@msnews.com>
wrote:

Joshua,

Doesn't work. I think it's a bug. I'll report it...
Try assigning DefaultButton to the ClientID of the button.

Something like this:
HtmlForm frm = (HtmlForm)Master.FindControl("formMain");
IButtonControlbtn = (IButtonControl)Master.FindControl("btnSubmit");
frm.DefaultButton = btn.ClientID;
txtCall.Focus();

Joshua Flanagan
http://flimflan.com/blog

Dec 15 '05 #6
On Wed, 14 Dec 2005 18:04:53 -0600, Joshua Flanagan <jo**@msnews.com>
wrote:

It's a bug. Here's the workaround...

HtmlForm frm = (HtmlForm)Master.FindControl("formMain");
Button btn = (Button)this.btnSubmit;
frm.DefaultButton = btn.UniqueID;

Try assigning DefaultButton to the ClientID of the button.

Something like this:
HtmlForm frm = (HtmlForm)Master.FindControl("formMain");
IButtonControlbtn = (IButtonControl)Master.FindControl("btnSubmit");
frm.DefaultButton = btn.ClientID;
txtCall.Focus();

Joshua Flanagan
http://flimflan.com/blog

Dec 15 '05 #7
Sorry, UniqueID is what I meant (didn't have the docs in front of me).
That is the correct behavior - it is not a bug.
Dec 15 '05 #8
On Thu, 15 Dec 2005 11:19:30 -0600, Joshua Flanagan <jo**@msnews.com>
wrote:
Sorry, UniqueID is what I meant (didn't have the docs in front of me).
That is the correct behavior - it is not a bug.

Dec 16 '05 #9
On Thu, 15 Dec 2005 11:19:30 -0600, Joshua Flanagan <jo**@msnews.com>
wrote:

When it was reported a year ago it was a bug. They simply rewrote the
help files to cover it. Check the bug history on it.
Sorry, UniqueID is what I meant (didn't have the docs in front of me).
That is the correct behavior - it is not a bug.

Dec 16 '05 #10

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

Similar topics

0
by: Jeff | last post by:
We have 3 environments, Dev, Qa, Prod. I'm working on an application that has a search page. On the search page is 3 panels. One panel is the advanced search, another a normal search and the...
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...
2
by: Oz Kologlu | last post by:
Hi folks, IE and Asp.net 2.0 are doing some pretty bizzare things. Some of our users were getting pretty weary of IE redrawing and "flashing" what is essentially a pretty static page every time...
7
by: Tim_Mac | last post by:
this is a re-post of an earlier message. i'm posting it under my MSDN alias for a better chance of reply :) when you press return in a multiline textbox, you expect to insert a newline. ...
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...
9
by: Veerle | last post by:
Hi, When you use multiple asp:Buttons on one Form, then asp.net generates html submit buttons for all of them. When you put your cursor in one of the textfields of the form, the default submit...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.