如何通过ajaxbeginform传递dropdownlist选择的值 [英] How to pass dropdownlist selected value through ajaxbeginform

查看:110
本文介绍了如何通过ajaxbeginform传递dropdownlist选择的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨Alll,



我想将Ajax.BeginForm中的dropdownlist选择值与其他一些控件传递给我的控制器,



这是我的代码,任何人的帮助或建议都表示赞赏



Hi Alll,

I wanted to pass dropdownlist selected value in Ajax.BeginForm with some other multiple controls to my Controller,

Here is my code,anyone's help or suggestions are appreciated

@using (Ajax.BeginForm("AddNewStore", "StoreRegistration", new AjaxOptions { HttpMethod = "POST", OnSuccess = "successOfAddition", OnFailure = "failureOfAddition" }, new { id = "addStoreRegisterForm" }))
                {
                    <div class="form-group col-md-6">
                        <div class="form-group">                           
                            @Html.DropDownListFor(x => x.StoreRegistrationAssociation.StoreIdentity, new SelectList(Model.StoreRegistrationAssociation.StoreIdentity, "Code", "Name", Model.StoreRegistrationAssociation.StoreIdentity), "Please Make a Selection", new { @class = "form-control", placeholder = "Please Make a Selection" })
                            @Html.ValidationMessageFor(x => x.StoreRegistrationAssociation.StoreIdentity)
                        </div>
                    </div>
                        <div class="form-group col-md-6">
                            <div class="form-group">
                                <!--[if gte IE 9]><div class="input-group"><span class="input-group-addon">Store Number</span><![endif]-->
                                @*<input type="text" placeholder="Store Number" value="" name="storeno" class="form-control" />*@
                                <!--[if gte IE 9]></div><![endif]-->
                                @Html.TextBoxFor(x => x.StoreRegistrationAssociation.StoreNumber, new { @class = "form-control", placeholder = "Store Number" })
                                @Html.ValidationMessageFor(x => x.StoreRegistrationAssociation.StoreNumber)
                            </div>
                        </div>
}







<div class="form-group">
                                    <input type="reset" value="Cancel" />
                                    <button type="submit" class="red-btn" data-dismiss="modal" id="btnRegisterStore">Agree</button>
                                </div>





在我的按钮上单击我获得SelectedIdentity值为Count = 0



我尝试了什么:



我尝试在我的ajax b中使用onchange事件egin form



函数AdditionalsChanged(){

selIdentity = $(#ddlIdentity)。val();

$(#ddlIdentity)。val(selIdentity);

}



@ Html.DropDownListFor(x => x.StoreRegistrationAssociation.StoreIdentity,new SelectList(Model.StoreRegistrationAssociation.StoreIdentity,Code,Name,Model.StoreRegistrationAssociation.StoreIdentity),Please Make a selection,new {@class =form-control,id = ddlIdentity,占位符=请做出选择})



On my button click i am getting the SelectedIdentity value as Count=0

What I have tried:

I have tried using onchange event in my ajax begin form

function AdditionalsChanged() {
selIdentity = $("#ddlIdentity").val();
$("#ddlIdentity").val(selIdentity);
}

@Html.DropDownListFor(x => x.StoreRegistrationAssociation.StoreIdentity, new SelectList(Model.StoreRegistrationAssociation.StoreIdentity, "Code", "Name", Model.StoreRegistrationAssociation.StoreIdentity), "Please Make a Selection", new { @class = "form-control",id="ddlIdentity", placeholder = "Please Make a Selection" })

推荐答案

(#ddlIdentity)。val();
("#ddlIdentity").val();


(#ddlIdentity)。val(selIdentity);

}



@ Html.DropDownListFor(x => x.StoreRegistrationAssociation.StoreIdentity,新的SelectList(Model.StoreRegistrationAssociation.StoreIdentity,Code,Name,Model.StoreRegistrationAssociation.StoreIdentity),请进行选择,新{@class =form-control ,id =ddlIdentity,占位符=请进行选择})
("#ddlIdentity").val(selIdentity);
}

@Html.DropDownListFor(x => x.StoreRegistrationAssociation.StoreIdentity, new SelectList(Model.StoreRegistrationAssociation.StoreIdentity, "Code", "Name", Model.StoreRegistrationAssociation.StoreIdentity), "Please Make a Selection", new { @class = "form-control",id="ddlIdentity", placeholder = "Please Make a Selection" })


这篇关于如何通过ajaxbeginform传递dropdownlist选择的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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