简体   繁体   English

将值从页面传递到引导模式和操作结果

[英]passing values from page to bootstrap modal and action result

I am working on an asp.net MVC 4 application. 我正在开发一个asp.net MVC 4应用程序。 I am using bootstrap to show modal. 我正在使用引导程序来显示模态。 In my index view, I have a rdiobutton list, a dropdown and a textbox and search button. 在索引视图中,我有一个rdiobutton列表,一个下拉列表以及一个文本框和搜索按钮。 When user will click search, I want to show bootstrap modal with values selected/types on main page and there will be some more textboxes on modal popup. 当用户单击搜索时,我想在首页上显示具有选定值/类型的引导模式,并且模式弹出窗口上还会有更多文本框。 How can I open the bootstrap using jquery and pass values to bootstrap popup ? 如何使用jquery打开引导程序并将值传递给引导程序弹出窗口?

    <input type="radio" name="inlineCheckbox1" value="option1">New
     <input type="radio" name="inlineCheckbox1" value="option2">Used                   
     <input type="radio" name="inlineCheckbox1" value="option3">Both

     <select id="myselect">
      <option>   option 1   </option>
      <option>   option 2   </option>
      <option>   option 3   </option>
      <option>   option 4   </option>
     </select

  <input class="span4" id="MonthlyPayment" type="text">

  <button id="btnAdvanceSearch" data-toggle="modal" class="btn btn-success btn-block" style="height: 40px; font-size: xx-large"><b>Search</b></button></td>


 @Html.Partial("~/views/Home/_AdvanceSearch.cshtml")

and my partial view is like a this 我的部分看法是这样的

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:700px">
    @using (Html.BeginForm("Search", "Home", FormMethod.Post, new { Id = "frmSearchVehicles" }))
    {


 @Html.TextBoxFor(model => model.DownPayment, new { @class = "span4" }) 
 @Html.TextBoxFor(model => model.DownPayment1, new { @class = "span4" }) 
 @Html.TextBoxFor(model => model.DownPayment2, new { @class = "span4" }) 
<input type="submt" value="search"
}

1)How can I open modal popup using jquery 2) how can I pass radio button, select and textbox value to modal popup 3) How can I pass all the values ( the ones radio button, select and textbox value on main page and modal popup) to action method ? 1)如何使用jquery打开模式弹出窗口2)如何将单选按钮,选择和文本框值传递给模式弹出框3)如何传递所有值(单选按钮,选择和文本框值在主页和模式上弹出)动作方法?

Please suggest 请建议

To show the dialog modal use the following: 要显示对话框模式,请使用以下命令:

$( "#myModal" ).modal('show');

Secondly, 其次,

To be able to pass your values to an action all you have to do is create a SearchCriteria Model class with the names of your inputs as properties 为了将值传递给操作,您要做的就是创建一个SearchCriteria Model类,并将输入的名称作为属性

public ActionResult Search(SearchCriteria model)
{

}

The problem is that your form is inside the modal, this is why you're not being able to pass them to the Action, what you need to do is put your Form outside the modal, this way when you post everything gets posted along, and you wouldn't have to pass the values to the modal itself. 问题在于您的表单位于模式内部,这就是为什么您无法将其传递给Action的原因,您需要做的就是将表单置于模式之外,这样,当您发布所有内容时,而且您不必将值传递给模态本身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM