且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MVC Ajax - 部分视图获取值但不刷新主视图

更新时间:2023-02-25 20:23:40

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


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

});

< / script>



以下是第二次下拉(部分查看:SelectClient)

@model HostingManager.Models.ContractManager



@if(Model.IClients!= null&& Model.IClients.Count()> 0)

{

使用(Ajax.BeginForm(SelectContracts,Contracts,新的AjaxOptions {UpdateTargetId =IContracts}))

{

@ Html.HiddenFor(m => m.SelectedGroupId)

@ Html.DropDownListFor(

m => m.SelectedClientId,

new SelectList (Model.IClients,id,cname),

string.Empty



}

}



< script type =text / javascript>
(this).parents(''form'').submit();
});
</script>

Below is Second Drop-down(Partial View : SelectClient)
@model HostingManager.Models.ContractManager

@if (Model.IClients != null && Model.IClients.Count() > 0)
{
using (Ajax.BeginForm("SelectContracts", "Contracts", new AjaxOptions { UpdateTargetId = "IContracts" }))
{
@Html.HiddenFor(m => m.SelectedGroupId)
@Html.DropDownListFor(
m => m.SelectedClientId,
new SelectList(Model.IClients, "id", "cname"),
string.Empty
)
}
}

<script type="text/javascript">


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