简体   繁体   中英

how to get value of html Input text placed inside ListView in asp.net C# code

I am having List view with Input Text box

If I am using asp TextBox and trying following Code while ItemUpdating, i am getting the value

obj.FName = (ObjView.Items[e.ItemIndex].FindControl("txtFName") as TextBox).Text;

how I have replace asp text box with html input text in aspx page, after which I am not getting the value

To get html input value in the code-behind, first take input as follows:

<input type="text" runat="server" id="Details" value= '<%# Eval("Details") %>' />

Then in the code-behind, use the following:

string details = ((HtmlInputText)row.FindControl("Details")).Value;

By the way, without controls, you can use the following for html inputs:

string details = Request.Form["Details"];

In that case, you should add a name attribute with the name Details .

To access any html input in your code behind, you must add runat="server" attribute for the control. Like below.

<input type="text" name="txtFName" id="txtFName" runat="server" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM