如何在表单集合键值中获取列表框ID? [英] How do I get list box id in my form collection key values?
本文介绍了如何在表单集合键值中获取列表框ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在提交给学生发放的书籍。因为我提交了一个列表框,用于为同一个学生发放多本书,当我提交表格时。在post方法中,我使用表单集合类从表单中检索所有值,当我检查表单集合键值时,它显示所有字段id但是列表框id没有显示在表单集合键中。
我尝试了什么:
这里是我用于显示列表框的代码
$(#FieldListTable)。append('
< input class =addNewButtonstyle =float:left; margin-left:0px; type =buttonvalue =添加id =btnAdd/>< input class =addNewButtonstyle =float:left; margin-left:0px;type =buttonid =btnRemove value =删除/> |
BOOkS LISt @ Html.ListBox(LstSignInAuthority ,Enumerable.Empty< SelectListItem>(),new {@id =LstSignInAuthority,style =width:200px; height:130px;}) |
解决方案
(#FieldListTable)。append('
< input class =addNewButtonstyle =float:left; margin-left:0px;type =buttonvalue =Addid =btnAdd/>< input class =addNewButtonstyle =float:left; margin-left:0px;type =buttonid =btnRemovevalue =Remove/> ');
BOOkS LISt
@ Html.ListBox(LstSignInAuthority,Enumerable.Empty< SelectListItem>(),new {@id =LstSignInAuthority,style =width:200px; height:130px;})
I am submitting books issued to students in form.for that i had kept one list box in that for issuing multiple books for same student,when i submit form. in post method i use form collection class to retrieve all values from form,when i check form collection key values it displays all fields id's but list box id is not showing in form collection key's.
What I have tried:
here the code which i used in view to display list box in the form
$("#FieldListTable").append('
<input class="addNewButton" style="float: left; margin-left: 0px;" type="button" value="Add" id="btnAdd" /><input class="addNewButton" style="float: left; margin-left: 0px;" type="button" id="btnRemove" value="Remove" /> |
BOOkS LISt @Html.ListBox("LstSignInAuthority", Enumerable.Empty<SelectListItem>(), new { @id = "LstSignInAuthority", style = "width:200px;height:130px;" }) |
解决方案
("#FieldListTable").append('
<input class="addNewButton" style="float: left; margin-left: 0px;" type="button" value="Add" id="btnAdd" /><input class="addNewButton" style="float: left; margin-left: 0px;" type="button" id="btnRemove" value="Remove" /> ');
BOOkS LISt
@Html.ListBox("LstSignInAuthority", Enumerable.Empty<SelectListItem>(), new { @id = "LstSignInAuthority", style = "width:200px;height:130px;" })
这篇关于如何在表单集合键值中获取列表框ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文