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.DropDownListFor(model => model.CustomerID, new SelectList(string.Empty, "Value", "Text"), "Please select a Customer", new { @class = "form-control required", type = "text" })
@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.DropDownListFor(model => model.CustomerContactID, new SelectList(string.Empty, "Value", "Text"), "Please select a ContactPerson", new { @class = "form-control", type = "text", id = "CustomerContactID" })
@Html.LabelFor(model => model.Description, new { @class = "control-label"})
@Html.TextAreaFor(model => model.Description, new { @class = "required" })
$.post("/VisitorsForm/ContactPersonCreate", CustomerContact, function (data) {
$('#CustomerContactID').append($('
alert("sucess");
window.close();
});
}
when i enter all the details and click the main save button it show error which is mentioned in the below image
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 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
no Ghouse Hussain i keep add button near to contact person to add the Contact person names if contact person not in the list while selecting Customer name. if i clcik that add button it will open one popup window to add the contact person..
remove button near the contact person & write code wen u select drplist automatically copy the text into textbox & then press save button it will work .here u did two times post back
Sneha KPosted Mar 31, 2016, 1:10 AM
Posted Mar 31, 2016, 1:01 AM