Asp.net MVC / jquery MODAL WONT SHOW [英] Asp.net MVC / jquery MODAL WONT SHOW

查看:53
本文介绍了Asp.net MVC / jquery MODAL WONT SHOW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在处理的视图和控制器,问题是当我按下提交按钮时它应该编辑数据并弹出一个警告编辑!并重定向到索引视图,但在这里它编辑数据,每次提醒模态没有数据:





 @model HFC.Models.Patient 

@ {
ViewBag.Title =Edit;
Layout =〜/ Views / Shared / _Layout.cshtml;
}

< h3>编辑患者< / h3>
< br />



@using(Html.BeginForm())
{
< form id =myForm>
< div class =container>
@ Html.AntiForgeryToken()

< div class =col-md-offset-1 col-md-6 col-xs-12 activeid =sidebar-right style =border:0.5px solid rgba(4,4,4,.4); margin-left:-30px; bottom:20px;
box-shadow:5px 5px 5px#99ccff; border-radius:5px ;>





< div class =row>

< div class =form-horizo​​ntal>
< h3 style =text-align:center; border-radius:5px; margin:1px; padding:10px; color:black> Personal Data< / h3>

< hr />

@ Html.ValidationSummary(true,,new {@class =text-danger})
@ Html.HiddenFor(model => model.Id)

< div class =form-group>
@ Html.LabelFor(model => model.FirstName_,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.FirstName_,new {htmlAttributes = new {@class =form-control}})
@ Html.ValidationMessageFor(model => model.FirstName_ ,,新{@class =text-danger})
< / div>
< / div>
< div class =form-group>
@ Html.LabelFor(model => model.LastName,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.LastName,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.LastName,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.DOB,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.DOB,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.DOB,,new {@class =text-danger})
< / div>
< / div>




< div class =form-group>
@ Html.LabelFor(model => model.Gender,Gender,htmlAttributes:new {@class =control-label col-md-3})
< div class = COL-MD-9\" >
@ Html.DropDownList(Gender,null,Select,new {@class =form-control})

@ Html.ValidationMessageFor(model => model。性别,,新{@class =text-danger})
< / div>
< / div>



< div class =form-group>
@ Html.LabelFor(model => model.PersonalNo_,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.PersonalNo_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.PersonalNo_,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.Weight_,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.Weight_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.Weight_,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.Height_,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.Height_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.Height_,,new {@class =text-danger})
< / div>
< / div>
< br />
< br />








< br />
< br />

< / div>

< / div>

< / div>




< div class =col-md-offset-1 col-md-6 col-xs-12 activeid =sidebar-右style =border:0.5px solid rgba(4,4,4,.4); margin-left:30px; bottom:20px;
box-shadow:5px 5px 5px#99ccff; border-radius: 5px;>
< div class =row>

< div class =form-horizo​​ntal>


< h3 style =text-align:center; border-radius:5px; margin:1px; padding:10px; color:black> Contact Data< / h3>
< hr />


< div class =form-group>
@ Html.LabelFor(model => model.Address1_,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.Address1_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.Address1 _,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.Address2,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.Address2,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.Address2,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.City,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.City,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.City,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.ZIPCode_,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.ZIPCode_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.ZIPCode_,,new {@class =text-danger})
< / div>
< / div>


< div class =form-group>
@ Html.LabelFor(model => model.Country_,Country_,htmlAttributes:new {@class =control-label col-md-3})
< div class = COL-MD-9\" >
@ Html.DropDownList(Country_,null,Select,new {@class =form-control})

@ Html.ValidationMessageFor(model => model。 Country_,,new {@class =text-danger})
< / div>
< / div>


< div class =form-group>
@ Html.LabelFor(model => model.Tel1_,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.Tel1_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.Tel1_,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.Tel2,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.Tel2,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.Tel2,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.Mobile,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.Mobile,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.Mobile,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.Email_,htmlAttributes:new {@class =control-label col-md-3})
< div class =col-md- 9\" >
@ Html.EditorFor(model => model.Email_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.Email_,,new {@class =text-danger})
< / div>
< / div>








< / div>
< / div>




< / div>


< div class =col-md-offset-1 col-md-6 col-xs-12 activeid =sidebar-rightstyle =border:0.5 px solid rgba(4,4,4,.4); margin-left:-30px;
box-shadow:5px 5px 5px#99ccff; border-radius:5px;>





< div class =row>

< div class =form-horizo​​ntal>
< h3 style =text-align:center; border-radius:5px; margin:1px; padding:10px; color:black> Health Data< / h3>

< hr />

< div class =form-group>
@ Html.LabelFor(model => model.BlodGroup_,BlodGroup_,htmlAttributes:new {@class =control-label col-md-4})
< div class = COL-MD-8\" >
@Html.DropDownList(BlodGroup_,null,Select,new {@class =form-control})

@ Html.ValidationMessageFor(model => model。 BlodGroup _,,new {@class =text-danger})
< / div>
< / div>



< div class =form-group>
@ Html.LabelFor(model => model.Alergies_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.Alergies_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.Alergies_,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.ChronicDiseases_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.ChronicDiseases_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.ChronicDiseases_,,new {@class =text-danger})
< / div>
< / div>


< div class =form-group>
@ Html.LabelFor(model => model.PatGroup1_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.PatGroup1_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.PatGroup1_,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.PatGroup2_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.PatGroup2_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.PatGroup2_,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.InsuranceCompany_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.InsuranceCompany_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.InsuranceCompany_,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.InsuranceCode_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.InsuranceCode_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.InsuranceCode_,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.InsuranceExpireDate_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.InsuranceExpireDate_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.InsuranceExpireDate _,,new {@class =text-danger})
< / div>
< / div>








< / div>

< / div>

< / div>




< div class =col-md-offset-1 col-md-6 col-xs-12 activeid =sidebar-右style =border:0.5px solid rgba(4,4,4,.4); margin-left:30px;
box-shadow:5px 5px 5px#99ccff; border-radius:5px;> ;
< div class =row>

< div class =form-horizo​​ntal>


< h3 style =text-align:center; border-radius:5px; margin:1px; padding:10px; color:black> Read Only Data< / h3> ;
< hr />



< div class =form-group>
@ Html.LabelFor(model => model.ProfessionalID_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.ProfessionalID_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.ProfessionalID_,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.InstitutionID_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.InstitutionID_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.InstitutionID _,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.UserId_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.UserId_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.UserId _,,new {@class =text-danger})
< / div>
< / div>

< div class =form-group>
@ Html.LabelFor(model => model.HCEID_,htmlAttributes:new {@class =control-label col-md-4})
< div class =col-md- 8\" >
@ Html.EditorFor(model => model.HCEID_,new {htmlAttributes = new {id =x,@ class =form-control}})
@ Html.ValidationMessageFor(model => model.HCEID_,,new {@class =text-danger})
< / div>
< / div>







< / div>
< / div>




< / div>









< / div>

< div class =btn-toolbarstyle =float:left;>
< br />
< input type =submitvalue =Saveclass =btn btn-primaryid =btnSubmit/>




< / div>
< / form>




}





< br /> ;

< script src =〜/ Scripts / jquery-1.10.2.min.js>< / script>

< script>
$(document).ready(function()
{

$(#btnSubmitT)。click(function(){



var data = $(#myForm)。serialize();
var newUrl ='@ Url.Action(Index,Patients)';

$ .ajax({
类型:POST,
url:/ Patients / Edit,
数据:数据,
成功:函数(响应){
$('#your-modal')。fadeTo(2000,600).slideUp(600,function(){
$('#your-modal')。slideUp(600);
window.location.href = newUrl;






});





},
错误:功能(响应){
//警报('无数据');
$('# your-modal2')。fadeTo(2000,600).slideUp(600,function(){
$('#your-modal2')。slideUp(600);

}) ;



}
})
})



})
< / script>

< script src =〜/ Scripts / jquery.validate.min.js>< / script>
< script src =〜/ Scripts / jquery.validate.unobtrusive.min.js>< / script>







< div class =alert alert-successid =your-modal隐藏= 隐藏 >
已编辑

< / div>

< div class =alert alert-warningid =your-modal2hidden =hidden>
无数据

< / div>



< style>
#your-modal {
text-align:center;
}



#your-modal2 {
text-align:center;
}


#x:悬停{
填充:15px;
border:1px solid#6699ff;
border-bottom-width:2px;
background-color:transparent;
}

.col-md-6.active:悬停{
box-shadow:2px 2px 2px 2px rgba(4,4,4,.4)!important;
}

.col-md-12.active:悬停{
box-shadow:2px 2px 2px 2px rgba(4,4,4,.4)!important;
}
< / style>





















b / b










< br $>




public ActionResult Edit([Bind(Include =Id,FirstName_,LastName,DOB,Gender,PersonalNo_,Address1_,Address2,City ,ZIPCode_,Country_,Tel1_,Tel2,Mobile,Email_,BlodGroup_,Alergies_,ChronicDiseases_,InsuranceCompany_,InsuranceCode_,InsuranceExpireDate_,UserId_,ProfessionalID_,InstitutionID_,HCEID_,Weight_,Height_,PatGroup1_,PatGroup2_)患者病人)

{

if(ModelState.IsValid)

{

db.Entry(patient).State = EntityState.Modified;

db.SaveChanges();

返回RedirectToAction(Index);

}

ViewBag.BlodGroup_ =新的SelectList(db.Patients,BlodGroup_ ,BlodGroup_,patient.BlodGroup_);

ViewBag.Gender = new SelectList(db.Patients,Gender,Gender,patient.Gender);



ViewBag.Country_ =新的SelectList(db.Patients,Country_,Country_,patient.Country_);



返回查看(患者);

}



我尝试过:



------------------------------------------ -----------------------

解决方案

(document).ready(function()
{


(#btnSubmitT)。click(function(){



var data =

( #myForm会)序列化();
var newUrl ='@ Url.Action(Index,Patients)';


This is the view that im working on and the controller , and the problem is when i press submit button it should edit data and popup an alert EDITED! and redirect to Index view , but here it edits the data and every time alert the modal NO DATA :


@model HFC.Models.Patient

@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h3>Edit Patient</h3>
<br />



@using (Html.BeginForm())
            {
    <form id="myForm">
        <div class="container ">
            @Html.AntiForgeryToken()

            <div class="col-md-offset-1 col-md-6 col-xs-12 active" id="sidebar-right" style="border: 0.5px solid rgba(4,4,4,.4)  ;margin-left:-30px;bottom:20px;
box-shadow: 5px  5px 5px #99ccff;  border-radius: 5px;  ">





                <div class="row">

                    <div class="form-horizontal">
                        <h3 style="text-align:center; border-radius:5px;margin:1px;padding:10px;color:black">Personal Data</h3>

                        <hr />

                        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                        @Html.HiddenFor(model => model.Id)

                        <div class="form-group">
                            @Html.LabelFor(model => model.FirstName_, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.FirstName_, new { htmlAttributes = new { @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.FirstName_, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <div class="form-group">
                            @Html.LabelFor(model => model.LastName, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.LastName, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.LastName, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.DOB, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.DOB, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.DOB, "", new { @class = "text-danger" })
                            </div>
                        </div>




                        <div class="form-group">
                            @Html.LabelFor(model => model.Gender, "Gender", htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.DropDownList("Gender", null, "Select", new { @class = "form-control" })

                                @Html.ValidationMessageFor(model => model.Gender, "", new { @class = "text-danger" })
                            </div>
                        </div>



                        <div class="form-group">
                            @Html.LabelFor(model => model.PersonalNo_, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.PersonalNo_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.PersonalNo_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.Weight_, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.Weight_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Weight_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.Height_, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.Height_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Height_, "", new { @class = "text-danger" })
                            </div>
                        </div>
                        <br />
                        <br />








                        <br />
                        <br />

                    </div>

                </div>

            </div>




            <div class="col-md-offset-1 col-md-6 col-xs-12 active" id="sidebar-right" style="border: 0.5px solid rgba(4,4,4,.4)  ;margin-left:30px;bottom:20px;
box-shadow: 5px  5px 5px #99ccff;  border-radius: 5px;  ">
                <div class="row">

                    <div class="form-horizontal">


                        <h3 style="text-align:center; border-radius:5px;margin:1px;padding:10px; color:black">Contact Data</h3>
                        <hr />


                        <div class="form-group">
                            @Html.LabelFor(model => model.Address1_, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.Address1_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Address1_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.Address2, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.Address2, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Address2, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.City, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.City, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.City, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.ZIPCode_, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.ZIPCode_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.ZIPCode_, "", new { @class = "text-danger" })
                            </div>
                        </div>


                        <div class="form-group">
                            @Html.LabelFor(model => model.Country_, "Country_", htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.DropDownList("Country_", null, "Select", new { @class = "form-control" })

                                @Html.ValidationMessageFor(model => model.Country_, "", new { @class = "text-danger" })
                            </div>
                        </div>


                        <div class="form-group">
                            @Html.LabelFor(model => model.Tel1_, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.Tel1_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Tel1_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.Tel2, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.Tel2, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Tel2, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.Mobile, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.Mobile, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Mobile, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.Email_, htmlAttributes: new { @class = "control-label col-md-3" })
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.Email_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Email_, "", new { @class = "text-danger" })
                            </div>
                        </div>








                    </div>
                </div>




            </div>


            <div class="col-md-offset-1 col-md-6 col-xs-12 active" id="sidebar-right" style="border: 0.5px solid rgba(4,4,4,.4)  ;margin-left:-30px;
box-shadow: 5px  5px 5px #99ccff;  border-radius: 5px;  ">





                <div class="row">

                    <div class="form-horizontal">
                        <h3 style="text-align:center; border-radius:5px;margin:1px;padding:10px;color:black">Health Data</h3>

                        <hr />

                        <div class="form-group">
                            @Html.LabelFor(model => model.BlodGroup_, "BlodGroup_", htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.DropDownList("BlodGroup_", null, "Select", new { @class = "form-control" })

                                @Html.ValidationMessageFor(model => model.BlodGroup_, "", new { @class = "text-danger" })
                            </div>
                        </div>



                        <div class="form-group">
                            @Html.LabelFor(model => model.Alergies_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.Alergies_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.Alergies_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.ChronicDiseases_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.ChronicDiseases_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.ChronicDiseases_, "", new { @class = "text-danger" })
                            </div>
                        </div>


                        <div class="form-group">
                            @Html.LabelFor(model => model.PatGroup1_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.PatGroup1_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.PatGroup1_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.PatGroup2_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.PatGroup2_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.PatGroup2_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.InsuranceCompany_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.InsuranceCompany_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.InsuranceCompany_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.InsuranceCode_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.InsuranceCode_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.InsuranceCode_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.InsuranceExpireDate_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.InsuranceExpireDate_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.InsuranceExpireDate_, "", new { @class = "text-danger" })
                            </div>
                        </div>








                    </div>

                </div>

            </div>




            <div class="col-md-offset-1 col-md-6 col-xs-12 active" id="sidebar-right" style="border: 0.5px solid rgba(4,4,4,.4)  ;margin-left:30px;
box-shadow: 5px  5px 5px #99ccff;  border-radius: 5px;  ">
                <div class="row">

                    <div class="form-horizontal">


                        <h3 style="text-align:center; border-radius:5px;margin:1px;padding:10px; color:black">Read Only Data</h3>
                        <hr />



                        <div class="form-group">
                            @Html.LabelFor(model => model.ProfessionalID_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.ProfessionalID_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.ProfessionalID_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.InstitutionID_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.InstitutionID_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.InstitutionID_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.UserId_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.UserId_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.UserId_, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.HCEID_, htmlAttributes: new { @class = "control-label col-md-4" })
                            <div class="col-md-8">
                                @Html.EditorFor(model => model.HCEID_, new { htmlAttributes = new { id = "x", @class = "form-control" } })
                                @Html.ValidationMessageFor(model => model.HCEID_, "", new { @class = "text-danger" })
                            </div>
                        </div>







                    </div>
                </div>


           

            </div>





           



            </div>

        <div class="btn-toolbar" style="float:left;">
            <br />
            <input type="submit" value="Save" class="btn btn-primary" id="btnSubmit" />




        </div>
        </form>

      


}
 




<br />

<script src="~/Scripts/jquery-1.10.2.min.js"></script>

<script>
    $(document).ready(function ()
    {

        $("#btnSubmitT").click(function () {



        var data = $("#myForm").serialize();
        var newUrl = '@Url.Action("Index","Patients")';

        $.ajax({
            type: "POST",
            url: "/Patients/Edit",
            data: data,
            success: function (response) {
                $('#your-modal').fadeTo(2000, 600).slideUp(600, function () {
                    $('#your-modal').slideUp(600);
                    window.location.href = newUrl;






                });





            },
            error: function (response) {
          //      alert('No Data ');
                $('#your-modal2').fadeTo(2000, 600).slideUp(600, function () {
                    $('#your-modal2').slideUp(600);

                });



            }
        })
        })



    })
</script>

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>







<div class="alert alert-success" id="your-modal" hidden="hidden">
    EDITED 

</div>

<div class="alert alert-warning" id="your-modal2" hidden="hidden">
    No Data

</div>



<style>
    #your-modal {
        text-align: center;
    }



    #your-modal2 {
        text-align: center;
    }


    #x:hover {
        padding: 15px;
        border: 1px solid #6699ff;
        border-bottom-width: 2px;
        background-color: transparent;
    }

    .col-md-6.active:hover {
        box-shadow: 2px 2px 2px 2px rgba(4,4,4,.4) !important;
    }

    .col-md-12.active:hover {
        box-shadow: 2px 2px 2px 2px rgba(4,4,4,.4) !important;
    }
</style>




















public ActionResult Edit([Bind(Include = "Id,FirstName_,LastName,DOB,Gender,PersonalNo_,Address1_,Address2,City,ZIPCode_,Country_,Tel1_,Tel2,Mobile,Email_,BlodGroup_,Alergies_,ChronicDiseases_,InsuranceCompany_,InsuranceCode_,InsuranceExpireDate_,UserId_,ProfessionalID_,InstitutionID_,HCEID_,Weight_,Height_,PatGroup1_,PatGroup2_")] Patient patient)
{
if (ModelState.IsValid)
{
db.Entry(patient).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.BlodGroup_ = new SelectList(db.Patients, "BlodGroup_", "BlodGroup_" , patient.BlodGroup_);
ViewBag.Gender = new SelectList(db.Patients, "Gender", "Gender", patient.Gender);

ViewBag.Country_ = new SelectList(db.Patients, "Country_", "Country_", patient.Country_);

return View(patient);
}

What I have tried:

-----------------------------------------------------------------

解决方案

(document).ready(function () {


("#btnSubmitT").click(function () { var data =


("#myForm").serialize(); var newUrl = '@Url.Action("Index","Patients")';


这篇关于Asp.net MVC / jquery MODAL WONT SHOW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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