[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 536
  • 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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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