0

As title, how should I do to get the input tool its "Name" from HTML by using asp.net C#.

The HTML code as follow:

<input type="number" Name="patientId" class="form-control" id="input1" runat="server">

What I tried in asp.net C# was this.input1.Name.ToString();, but the name I got was same with id "input1", not the one "patientId".

Does anyone know how to do that?

HCCY
  • 91
  • 1
  • 9
  • I think this explains your question. http://stackoverflow.com/a/2684266/5068518 – dave querubin Apr 12 '17 at 02:34
  • Also, you can spot difference between `id` & `name` in HTML context: http://stackoverflow.com/questions/1397592/difference-between-id-and-name-attributes-in-html. You can capture control ID as target, but you need to use postback submit for identifying name attribute. – Tetsuya Yamamoto Apr 12 '17 at 04:38
  • It's worth asking "why" or "what for", before you get into possible "unnecessary" things. – EdSF Apr 12 '17 at 04:57
  • The reason why I wanna get both value from name and id is because I wanna use a for loop to read all the input tool in a webpage by using "input" + i and then also get the meaning of this input tool by getting from its name. – HCCY Apr 13 '17 at 05:27

0 Answers0