ACP
ACP

Reputation: 35264

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

Hai guys,
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...

Upvotes: 0

Views: 228

Answers (3)

Paddy
Paddy

Reputation: 33877

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

Wikipedia ref

Upvotes: 0

Jørn Schou-Rode
Jørn Schou-Rode

Reputation: 38406

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"];

Upvotes: 3

this. __curious_geek
this. __curious_geek

Reputation: 43217

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

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

Upvotes: 1

Related Questions