O. Kaan O. Kaan - 2 months ago 4x
ASP.NET (C#) Question

Cant get values of inputs asp.net

My problem i always get null from my inputs or default value. Some how if i set value at page_load like Form_txt_Ad.Value="ExampleValue"; i can get it. But i cant get any value from inputs.

protected void Save_Button_Click(object sender, EventArgs e)
string exapmle = Form_txt_Ad.Value;
string example = Form_txt_Soyad.Value;4

<div class="input">
<input type="text" translate translate-attr-placeholder=".PLACEHOLDER_NAME" placeholder="Ad" id="Form_txt_Ad" runat="server" />
<span><i class="glyphicon glyphicon-user"></i></span>

<div class="col-md-12" style="text-align: center;">
<button type="button" runat="server" onserverclick="Save_Button_Click" class="btn btn-success btn-raised btn-lg" title="Kaydet"><i class="glyphicon glyphicon-floppy-saved icon-marginRight"></i>Kaydet</button>

Thx for help.


Make sure all your control elements are placed inside <form> ... </form> tag.

Since you have placed runat="server" you should be able to get the value by either using any of them




Else use Request.Form["Form_txt_Ad"]

Not sure though why not use a server side control using <asp:TextBox ... which will allow you to get the textbox value directly using the Text property