mvc-System.Web.Mvc.ViewUserControl
嘿... 如何在后操作中将提交按钮的 id 从 ViewUserControl 发送到控制器?当我有正常的视图时,我可以写这样的东西:
[HttpPost]
public ActionResult KontaktIzabran(string myId)
{
//some code
}
Now myId is alwasy null.... 这是我的用户控件
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<KontaktModel>" %>
<%@ OutputCache Duration="1200" VaryByParam="*" %>
<div id="sign-in-pop" class="popup">
<div class="modal fat-form">
<div class="clipper">
<div class="left"></div>
<div class="content">Sign In</div>
<div class="right"></div>
</div>
<% Html.BeginForm("IzborKontaktaPopUp", "Kontakt"); %>
<%: Html.ValidationSummary(true) %>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Naziv)%>
<%: Html.ValidationMessageFor(model => model.Naziv) %>
<input type="submit" value="Traži" name="submitButton" id="submitButton" />
<input type="submit" value="Dodaj novi" name="noviKontakt" />
</div>
<% Html.EndForm(); %>
</div>
</div>
Hey...
How can I send submit buttons'id from ViewUserControl to controler on post action? When I had normal view I could write something like this:
[HttpPost]
public ActionResult KontaktIzabran(string myId)
{
//some code
}
Now myId is alwasy null....
Here is my UserControl
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<KontaktModel>" %>
<%@ OutputCache Duration="1200" VaryByParam="*" %>
<div id="sign-in-pop" class="popup">
<div class="modal fat-form">
<div class="clipper">
<div class="left"></div>
<div class="content">Sign In</div>
<div class="right"></div>
</div>
<% Html.BeginForm("IzborKontaktaPopUp", "Kontakt"); %>
<%: Html.ValidationSummary(true) %>
<div class="editor-field">
<%: Html.TextBoxFor(model => model.Naziv)%>
<%: Html.ValidationMessageFor(model => model.Naziv) %>
<input type="submit" value="Traži" name="submitButton" id="submitButton" />
<input type="submit" value="Dodaj novi" name="noviKontakt" />
</div>
<% Html.EndForm(); %>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,看起来您没有名为“myId”的表单字段,因此提交无法将其发送回控制器。相反,它会发回一个包含当前值的 FormCollection:
Well it looks like you don't have a form field called "myId", so the submit can't send that back to the controller. Instead it will send back a FormCollection containing the current values of these: