如何在控制器页面中获取选择标记值? [英] how will I get select tag value in controller page?
问题描述
@ Html.LabelFor(model => model.AlbumId,Please Album Name)
@ Html.DropDownListFor(m => m.albums,Model.albums,Please Select ,new {@id =albums,@ class =state,@ onchange =javascript:GetSongs(this.value);})
@ Html.LabelFor(model => model.SongId,请选择歌曲)
< select id =ddlsongs name =ddlsongsclass =state>< / select>
< input name =songname type =submitclass =button1value =点击生成链接/>
我认为你可以在控制器中使用表单集合参数你的所有控制值都来自控制器。
例如
< br />
Public ActionResult test(FormCollection集合)< br />
{< br />
//您可以获得任何值,例如< br />
collection [input]< br />
< br />
}
public ActionResult Save( string ddlsongs)
{
// 您的代码在这里......
}
其中ddlsongs是您问题中的选择标记的名称。
@Html.LabelFor(model => model.AlbumId, "Please Album Name")
@Html.DropDownListFor(m => m.albums, Model.albums, "Please Select", new { @id = "albums", @class = "state", @onchange = "javascript:GetSongs(this.value);" })
@Html.LabelFor(model => model.SongId, " Please Select Song ")
<select id="ddlsongs" name="ddlsongs" class="state" ></select>
<input name="songname" type="submit" class="button1" value="Click to generate link"/>
I think you can use form collection parameter in controller in which your all controls value comes at controller.
e.g.
<br /> Public ActionResult test(FormCollection collection)<br /> {<br /> //you can get any value like <br /> collection["input"]<br /> <br /> }
You can also add a parameter with the name of select tag in your controller like so
public ActionResult Save(string ddlsongs) { //Your code here... }
where ddlsongs is the name of select tag like the one in your question.
这篇关于如何在控制器页面中获取选择标记值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!