Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Form Button in FireFox

Tags:

asp.net

vb.net

I am building a server control that will search our db and return results. The server control is contains an ASP:Panel. I have set the default button on the panel equal to my button id and have set the form default button equal to my button id.

On the Panel:

 MyPanel.DefaultButton = SearchButton.ID

On the Control:

Me.Page.Form.DefaultButton = SearchButton.UniqueID 

Works fine in IE & Safari I can type a search term and hit the enter key and it searches fine. If I do it in Firefox I get an alert box saying "Object reference not set to an instance of an a object.

Anyone run across this before?

like image 208
brendan Avatar asked Aug 08 '08 15:08

brendan


People also ask

What is the default type of button in form?

For most browsers the default type of button is submit . This attribute declares the type of the button.

What is a form button?

Form buttons allow the user to submit the filled-in form to the server for processing. Your form will generally contain at least one form submit button so that the form can be sent.

Can you use a button to submit a form?

Using submit buttons. <input type="submit"> buttons are used to submit forms. If you want to create a custom button and then customize the behavior using JavaScript, you need to use <input type="button"> , or better still, a <button> element.


2 Answers

Is SearchButton a LinkButton? If so, the javascript that is written to the browser doesn't work properly.

Here is a good blog post explaining the issue and how to solve it:

Using Panel.DefaultButton property with LinkButton control in ASP.NET

like image 137
Otto Avatar answered Sep 28 '22 22:09

Otto


Ends up this resolved my issue:

     SearchButton.UseSubmitBehavior = False
like image 22
brendan Avatar answered Sep 28 '22 22:09

brendan