Home All Groups Group Topic Archive Search About

asp button always rendered as type="button" vs. type="submit"

Author
13 Nov 2008 7:06 PM
Sam
I have a User Control that renders all asp buttons as Command button
vs. Submit buttons.  When you view source on the browser you see the
HTML rendered:

<input type="button" ... >

instead of

<input type="submit" ...>

I am aware there is a property for the button control named
UseSubmitBehavior.  The default is true and I have explicitly set this
to true, but I still cannot get the button to render as a Submit
button.  Has anyone seen this behavior and have a workaround?

Thanks,

Sam

Author
25 Nov 2008 6:14 PM
Brian Kenneth Nielsen
Hi Sam

Why would you like a submit button?

ASP.Net only allows one server side form anyway. And if you have
multiple "forms" on the page, it will be a problem, if they all had
type=Submit buttons.

That's properly why you don't see a real submit button.

If you have the common problem about which button that is the default
button, then put your subform into a <asp:Panel> and place your Command
Button inside that. then set asp:panels defaultButton property to the ID
of your Command Button. That way your button will be called when user
eg. press ENTER key in one of the forms fields.

In that way you can both a login form, search form, tip a friend form on
the same page, with different default buttons.

Best regards
Brian Kenneth Nielsen
http://www.bknnet.dk/


Sam wrote:
Show quoteHide quote
> I have a User Control that renders all asp buttons as Command button
> vs. Submit buttons.  When you view source on the browser you see the
> HTML rendered:
>
> <input type="button" ... >
>
> instead of
>
> <input type="submit" ...>
>
> I am aware there is a property for the button control named
> UseSubmitBehavior.  The default is true and I have explicitly set this
> to true, but I still cannot get the button to render as a Submit
> button.  Has anyone seen this behavior and have a workaround?
>
> Thanks,
>
> Sam