ASP.NET 2.0: Multiple problems with DefaultButton

G

Guest

I am facing some issues with the webforms DefaultButton functionality:

#1 One text box ==> hitting enter works in IE but not in Firefox (1.5)
#2 One text box and req. field validator ==> problem in IE
#3 two text boxes ==> not even a postbak in Firefox.

The three problems I have could be simply reproduced creating a new webform
and pasting the code below in the codebehind file.

TextBox bx1;
TextBox bx2;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
Validate();

bx1 = new TextBox();
bx1.ID = "bx1";

//bx2 = new TextBox(); // uncomment this line for problem #3
//bx2.ID = "bx2"; // uncomment this line for problem #3

RequiredFieldValidator rf = new RequiredFieldValidator();
rf.ControlToValidate = bx1.ID;
rf.EnableClientScript = true;
rf.ErrorMessage = "mandatory";


LinkButton lbSubmit = new LinkButton();
lbSubmit.ID = "lbSubmit";
lbSubmit.Click += new EventHandler(lbSubmit_Click);
lbSubmit.Text = "submit";

form1.DefaultFocus = bx1.ID;
form1.DefaultButton = lbSubmit.ID;

form1.Controls.Add(bx1);
//form1.Controls.Add(bx1); // uncomment this line for problem #3
//form1.Controls.Add(rf); // uncomment this line for problem #2
form1.Controls.Add(lbSubmit);

}

void lbSubmit_Click(object sender, EventArgs e)
{
form1.Controls.Add(new LiteralControl("lbSubmit_Click: Text is: " +
bx1.Text));
}


Finally, more detailed description of the problems:

Problem #1:
Adding text in the textbox and hitting enter works in IE like expected: my
Click handler of the submit button is called.
However, this does not work in Firefox. Postback is triggered, but the click
handler is not called. My workaround for this is inserting the follwoign code
in Page_Load:
if (IsPostBack && Request.Form["__EVENTTARGET"] == "")
Search(this, EventArgs.Empty);


Problem #2:
If I add a required field validator for the text box (uncomment
form1.Controls.Add(rf); in code above), I am getting problems in IE, too:
When entering no text in the textbox and just hitting enter, the field
validator tells me I need to add text. After adding text and hitting enter,
thepostback is done but the click handler is not called.
If I then once again hit enter, another postback in done and now the click
handler is called.

Problem #3:
If I add an additional textbox to the form, Firefox will even stop doing the
postback!


Any help would be greatly appreciated.
Dieter
 
Y

Yuan Ren[MSFT]

Hi Dieter,

Thanks for posting!

For the current issue, all problems have been performed and reproduced on
my machine.

For the first and third, based on my experience, the problem is caused by
the behavior of the Firefox browser. The linkbutton control which is parsed
in the Firefox browser is different with the IE browser. After performing
some tests, I suggest you use the button control instead of the linkbutton.

For the second, it seems the JavaScript function for the validation control
leads to the current issue. I¡¯ll discuss with the Dev team about it. It
will take some time to determine some factors. I¡¯ll reply to you ASAP when
I get some information. I appreciate your understanding!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 
G

Guest

Hello Yuan,

thanks for your reply.

After performing
some tests, I suggest you use the button control instead of the linkbutton.
I prefer to use LinkButtons since they are prettier.
Is the malfunctioning of the DefaultButton property in Firefox (issues #1
and #3) a bug or by design? There is no hint in the online help for
DefaultButton that this just works for IE.
For the second, it seems the JavaScript function for the validation control
leads to the current issue. I¡¯ll discuss with the Dev team about it. It
will take some time to determine some factors. I¡¯ll reply to you ASAP when
I get some information. I appreciate your understanding!
OK, thanks for the info.
 
Y

Yuan Ren[MSFT]

Hi Dieter,

Thanks for your reply!

For the second issue, I suggest you open a new case to the Microsoft PSS.
Since the issue maybe is caused by the product bug, you will not be charged
for the case. The Microsoft PSS will supply the workaround or hot fix for
the current issue.

For your reference, I attached steps to contact Microsoft PSS here: You can
contact Microsoft Product Support directly to discuss additional support
options you may have available, by contacting us at 1-(800)936-5800 or by
choosing one of the options listed at
http://support.microsoft.com/common/international.aspx?rdpath=gp;en-us;offer
prophone

For the first and third, since the html code and JavaScript code which are
rendered by the IE or Firefox browser are same, I don't think this is an
ASP.NET issue. Because the same code can be worked fine for the IE browser
but not for the Firefox, I suggest you contact some support specialist for
Firefox to find the key factor.

Thanks for your understanding!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 

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

Top