如何停止向actionMethod发送选择下拉列表? [英] how to stop sending on selection of drop downlist to a actionMethod?

查看:75
本文介绍了如何停止向actionMethod发送选择下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表格有一个

I have a form which have one

@using (Html.BeginForm("Details", "Home", FormMethod.Post))
    {
 <div class="FormContainer">
                
                    <table>
                        <tr>
                            <td class="Label">
                                @Html.Label("*Name of District")
                            </td>

                            <td>
                                
                                <div class="ddl1">
                                    @Html.Partial("_District")
                                   
                                </div>
                               

                            </td>
                        </tr>

                        <tr>
                            <td class="Label">
                                @Html.Label("*Name of Tehsil")
                            </td>

                            <td>
                                <div id="tehsil" class="ddl2">
                                    @Html.Partial("_Tehsil")
                                </div>
                            </td>
                        </tr>

                        <tr>
                            <td class="Label">
                                @Html.Label("*Name of Sub Tehsil")
                            </td>

                            <td>
                                <div id="Subtehsil">@Html.Partial("_SubTehsil", Model)</div>
                                
                            </td>
                        </tr>

                        <tr>
                            <td class="Label">
                                @Html.Label(" Village")
                            </td>
                            <td class="txbox">
                                @Html.TextBox("Village", null, new { @class = "txtbox" })
                            </td>
                        </tr>

                        <tr>
                            <td class="Label">
                                @Html.Label("*Name of Applicant")
                            </td>
                            <td class="txbox">
                                @Html.TextBox("NameOfApplicant", null, new { @class = "txtbox" })
                            </td>
                        </tr>

                        <tr>
                            <td class="Label">
                                @Html.Label("*Name of Land Owners / Owners")
                            </td>
                            <td class="txbox">
                                @Html.TextBox("NameOfLandOwners", null, new { @class = "txtbox" })
                            </td>
                        </tr>
</table>
}</div>





和_District,_tehsil,_subtehsil部分视图我有以下





and in _District , _tehsil, _subtehsil partial view i have following

Quote:

</blockquote>



@using (Ajax.BeginForm("Selecttehsil", "Home", new AjaxOptions { UpdateTargetId = "tehsil" }))
{

    @Html.DropDownListFor(m => m.SelectedDistrictId, 
                        new SelectList(Model.Districts, "DistrictId", "DistrictName"), 
                        "----Select District----", 
                        new { @class = "ddl" }
    )
 
}

<script type="text/javascript">
   
        $('#SelectedDistrictId').change(function () {
            $(this).parents('form').submit();
          
        });
   
</script>





_tehsil部分视图





_tehsil partial view

@if (Model.Tehsils != null && Model.Tehsils.Count() > 0)
{ 
using (Ajax.BeginForm("Selectsubtehsil", "Home", new AjaxOptions { UpdateTargetId = "Subtehsil" }))
{    
    @Html.HiddenFor(m => m.SelectedDistrictId)
    @Html.DropDownListFor(m => m.SelectedTehsilId, new SelectList(Model.Tehsils, "TehsilId", "TehsilName"), "----Select Tehsil-----", new {@class = "ddl" })
}

}
<script type="text/javascript">
    $('#SelectedTehsilId').change(function () {
        $(this).parents('form').submit();
     
    });
</script>





_subtehsil局部视图





_subtehsil Partial view

@if (Model.SubTehsils != null && Model.SubTehsils.Count()>0)
{ 
    @Html.DropDownList("SubTehsils", new SelectList(Model.SubTehsils, "SubTehsilId", "SubTehsilName"), "----Select SubTehsil---", new { @class = "ddl"})
}





当我从下拉列表中选择一个项目时发布到详细信息行动我点击提交按钮时想要它做的方法。请告诉我一个方法。



when i select an item from dropdownlist it get posted to "Details" action method which i want it to do when i click on submit button. Please tell me a way out here.

推荐答案

' #SelectedDistrictId')。change(function(){
('#SelectedDistrictId').change(function () {


this )。 (' form')。submit();

});

< / script >
(this).parents('form').submit(); }); </script>





_tehsil部分视图





_tehsil partial view

@if (Model.Tehsils != null && Model.Tehsils.Count() > 0)
{ 
using (Ajax.BeginForm("Selectsubtehsil", "Home", new AjaxOptions { UpdateTargetId = "Subtehsil" }))
{    
    @Html.HiddenFor(m => m.SelectedDistrictId)
    @Html.DropDownListFor(m => m.SelectedTehsilId, new SelectList(Model.Tehsils, "TehsilId", "TehsilName"), "----Select Tehsil-----", new {@class = "ddl" })
}

}
<script type="text/javascript">


' #SelectedTehsilId')。change(function(){
('#SelectedTehsilId').change(function () {


这篇关于如何停止向actionMethod发送选择下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆