What is the difference in functionality between
<asp:Button id="button1" Text="Click me" runat="server" OnClick="submitEvent" />
and
<input type="button" id="button1" runat="server" value="Click me" />
Does the input with runat=”server” attribute has other or limited properties and methods?
Thank you!
The first one creates a
System.Web.UI.WebControls.Buttonwhile the second one creates aSystem.Web.UI.HtmlControls.HtmlInputButton.Both are server controls, but the controls in the
WebControlsnamespace generally has a bit more functionality than the controls in theHtmlControlsnamespace. Typically they put some data inViewStateto keep track of their state, and they have server side postback events.Each controls in the
HtmlControlsnamespace correspond exactly to an HTML element, while the controls in theWebControlsnamespace may be rendered differently depending on what the browser that is requesting the page can support.