• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 539
  • Last Modified:

generate textbox id dynamically

<td class="ssTdAlt">
 <% var id = i; %>
 <%= Html.TextBox("txtprice",item.Price, new { @class = "Tbox",size="3"})%>
 <%-- <input type="text" id="Text1" maxlength="25" class="inputbox" style="height: 15px;"
 size="10" value="10" />--%>
</td>

Here i want to generate textbox id dynamically,like according to the var id i it should be look like as below

txtprice1
txtprice12
txtprice13

could you please let me know how to write syntax

<%= Html.TextBox("txtprice",item.Price, new { @class = "Tbox",size="3"})%>




0
nicemanish
Asked:
nicemanish
  • 2
1 Solution
 
crisco96Commented:
<%= Html.TextBox("txtprice",item.Price, new { @class = "Tbox",size="3", id=id})%>
0
 
crisco96Commented:
Oh sorry id is just a number if you want it prefixed with txtprice do the following:
<%= Html.TextBox("txtprice",item.Price, new { @class = "Tbox",size="3", id="txtprice" + id.ToString()})%>
0
 
nicemanishAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now