Hi in my view i have two buttons. One is near to Contact Person and another one is main Savebutton.If I select the Customer Name the customer name related Contact Person name will load automatically in contact person drop down.its like cascading drop down.
Suppose if i enter the Employee, Date,Customer Name ,Visit type , POVisit and select the Contact person(the Contact Person will load automatically based on the selection of customer name). Suppose the contact person is not in the list means i have to add that . so i click that add button near to contact person.it open Contact Person Partial View as popup window (and i enter the details and save the details and close the popup window.
Now all are working fine but now i got one new issue. if i enter the Employee, Date,Customer Name ,Visit type , POVisit and add the contact person( by clicking the add button), Department , Designation etc and click the Save button(Main Save Button which is in blue color), the data is not saving into the database.
But if i enter all the details and click the button which is near to the Contact Person the whole data is saving in the database . This is the issue if i enter all the details and click the main save buttons means its not saving the data in database but at the same time if i click the button which is near to contact person it saving the data in db. I tried to explain my issue as per my level best. please any one help to resolve the issue.
My View Model (Visitors View Model)public class VisitorsViewModel
{
public Nullable Date { get; set; }
public System.Guid VisitingID { get; set; }
public Nullable EmployeeID { get; set; }
public string EmployeeName { get; set; }
public Nullable CustomerID { get; set; }
public string CustomerName { get; set; }
public bool VisitType { get; set; }
public System.Guid POVisitID { get; set; }
public string POVisit { get; set; }
public Nullable CustomerContactID { get; set; }
public Nullable ContactID { get; set; }
public string ContactPerson { get; set; }
public string Department { get; set; }
public Nullable DesignationID { get; set; }
public string Designation { get; set; }
public Nullable NextActivityID { get; set; }
public string NextActivity { get; set; }
public Nullable NextAppointmnet { get; set; }
public string Description { get; set; }
}I created the properties of fields which is used in popup windows also created in the same view model.
My Parent view Visitors form i declare some fields here
@Html.Label("Employee Name", new { @class = "control-label" })
@Html.DropDownList("EmployeeID", null, "Select", new { @class = "form-control" })
@Html.Label("Customer Name", new { @class = "control-label" }) @Html.Label("Purpose of Visit", new { @class = "control-label", styles = "font-family: Arial;" })
@Html.DropDownList("POVisitID", null, "Select", new { @class = "form-control required" })
@Html.Label("Contact Person", new { @class = "control-label" }) @Html.LabelFor(model => model.Description, new { @class = "control-label"})
@Html.TextAreaFor(model => model.Description, new { @class = "required" })
@Html.ValidationMessageFor(model => model.Description) open: function(event, ui) {
$(this).load("@Url.Action("ContactPersonPartialView", "VisitorsForm")");
},
buttons: {
"Close": function () {
$(this).dialog("close");
}
}
});
$("#AddContactPerson").click(function () {
$("#AddNewContactPerson").dialog("open");
});
});@Html.Label("Customer Name")
@Html.DropDownList("CustomerID", null, "Select", new { @class = "form-control " ,id="Customer"})
@Html.LabelFor(model => model.ContactPerson)
@Html.TextBoxFor(model => model.ContactPerson, new { @class = "form-control", type = "text"})
@Html.ValidationMessageFor(model => model.ContactPerson)function SaveContact() {
debugger;
var CustomerID = $("#Customer").val();
var ContactPerson = $("#ContactPerson").val();
var Email = $("#EmailID").val();
var AlternateEmail = $("#AlternateEmail").val();
var PhoneNo = $("#PhoneNo").val();
var MobileNo = $("#MobileNumber").val();
var CustomerContact = { };
$.post("/VisitorsForm/ContactPersonCreate", CustomerContact, function (data) {
$('#CustomerContactID').append($('').val(data).text(ContactPerson));
alert("sucess");
window.close();
});
}
My Question is very long but please any one understand my issue and give me one solution and i request you to check my j query coding again..if any one didn't understand my question means please ask with me..
Advance thanks.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Former memberPosted Mar 30, 2016, 9:01 PM EDT
Sneha KRank #3,184 · 446 pointsPosted Mar 30, 2016, 9:10 PM EDT