开发者

Is it possible to submit a form in asp.net without any server controls

Hai guys,

开发者_C百科 I had this doubt for a long time now. Now being a part of stackoverflow i ve decided to ask it... Consider form without Runat="server" and it contains two html text boxes and a html button all without Runat="server", now my is it possible to submit this form and i have to insert the values in my DB...


If your "HTML button" is a <input type="submit" /> element, clicking it will indeed cause the <form> to be posted. However, it will not raise any Click events, since there is no Button object associated with the HTML button you have clicked.

In your Page_Load() method (or similar) you will be able to retrieve the posted values using the Request.Form collection. Example with text input has name="myField":

string postedVal = Request.Form["myField"];


Yes. You can read the values from those controls by using

var valueFromHtmlControl = Request.Form["Control-Identified"]


Absolutely - this can lead to some unwanted effects, such as cross site request forgery, which is worth looking out for:

Wikipedia ref

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜