I get a structure like this:
<asp:TextBox runat="server" ID="txt"/>
<input runat="server" id="btn" onserverclick="btn_Click" type="image" src="demo.png"/>
When I input something in the textbox and hit Enter, the method btn_Click can be called. but when disabled javascript, it can not postback and the btn_Click method can not be called.
What’s wrong with this?
Any help, thanks.
Most of the ASP.NET server side controls use JavaScript to post a
formtag that surrounds the entire page content (look for the<form runat="server">tag in your source files, or for<form name="aspnetForm">in the HTML source in your browser).Really, this behavior is so tightly engrained in WebForms, the use of 1
formtag for the entire page, and hidden inputs for the ViewState, event target, command argument, etc.If you need functionality without JavaScript, you’ll need a back to basics approach of simply relying on the HTTP protocol, by using just
GETandPOSTrequests with your ownformtags (which can’t be nested), and regularatags.Honestly, if you need functionality without JavaScript, it would probably be easier to switch over to ASP.NET MVC.