In Razor View how to access the Id of dynamically created number of textbox -


i trying create number of text box dynamically in razor view. how can ensure different id assigned each of text box dynamically? objective access numeric value entered in dynamic textbox (questioncount) , calculate sum of values entered.

below part of code used in view.

@foreach (var qp_count in viewbag.nonuniformtempcount) {  var str = @viewbag.nonuniformtempnames[tempindex];  <b>@str</b>  (int qcount = 1; qcount <= qp_count; qcount++)    {      **<br /> <b>@qcount</b>  <b>@html.textbox("questioncount")</b>**                               }  tempindex++; } 

in order give different id's dynamicaly generated textboxes try :-

@foreach (var qp_count in viewbag.nonuniformtempcount) {   var str = @viewbag.nonuniformtempnames[tempindex];   <b>@str</b>   (int qcount = 1; qcount <= qp_count; qcount++)   {     <br /> <b>@qcount</b> <b>@html.textbox("questioncount",null,new{ id = "question-" + @qcount + @qp_count })</b>                             }   tempindex++; } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -