Can you show me your view code....
It should be like this view code
@using (@Html.BeginForm("ImportContacts", "Outlook", FormMethod.Post, new { id = "Importform" }))
{
@Html.ValidationSummary(true, "Please fill the form correctly and try again.");
@Html.LabelFor(model => model.FirstName)*
@Html.TextBoxFor(mode => Model.FirstName)
@Html.ValidationMessageFor(model => Model.FirstName)
@Html.LabelFor(model => model.LastName)*
@Html.TextBoxFor(mode => Model.LastName)
@Html.ValidationMessageFor(model => Model.LastName)
@Html.LabelFor(model => model.Title)
@Html.TextBoxFor(mode => Model.Title)
@Html.LabelFor(model => model.BusinessTelephoneNumber)*
@Html.TextBoxFor(mode => Model.BusinessTelephoneNumber)
@Html.ValidationMessageFor(model => Model.BusinessTelephoneNumber)
@Html.LabelFor(model => model.MobileTelephoneNumber)
@Html.TextBoxFor(mode => Model.MobileTelephoneNumber)
@Html.LabelFor(model => model.BusinessFaxNumber)
@Html.TextBoxFor(mode => Model.BusinessFaxNumber)
@Html.LabelFor(model => model.Email1Address)*
@Html.TextBoxFor(mode => Model.Email1Address)
@Html.ValidationMessageFor(model => Model.Email1Address)
<input type="submit" id="submitform" value="Save" />
<input type="button" id="buttonclose" value="Cancel" onclick="closeWindow()" />
<script type="text/javascript">
/*
jquery called on form submit to save the data.
on Success closes the popup form.
*/
$('#Importform').submit(function (e) {
e.preventDefault();
$.post(this.action, $(this).serialize(), function (response) {
// alert(response.toString());
if (response.toString().toLowerCase() == "success") {
//alert(response.error);
$("#Importform").closest(".k-window-content").data("kendoWindow").close();
}
}, 'json');
});
/*
javascriot method called on click of close button.
closes the popup form.
*/
function closeWindow() {
$("#buttonclose").closest(".k-window-content").data("kendoWindow").close();
}
</script>
}
The model code for this is.....
public class OutlookContact
{
[Display(Name="Title")]
public string Title { get; set; }
[Required(ErrorMessage="Please enter first name.")]
[Display(Name="First Name")]
public string FirstName { get; set; }
[Required(ErrorMessage = "Please enter last name.")]
[Display(Name = "Last Name")]
public string LastName { get; set; }
[Required(ErrorMessage="Please enter email address.")]
[Display(Name="Email")]
[RegularExpression(@"^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4})$", ErrorMessage = "Invalid email address")]
[DataType(DataType.EmailAddress, ErrorMessage = "Invalid email address")]
public string Email1Address { get; set; }
public string BusinessAddressStreet { get; set; }
public string BusinessAddress { get; set; }
public string BusinessAddressCity { get; set; }
public string BusinessAddressState { get; set; }
[Display(Name="Phone")]
[Required(ErrorMessage = "Please enter phone number")]
[RegularExpression(@"^[0-9]{7,15}$", ErrorMessage = "Invalid phone number.")]
[DataType(DataType.PhoneNumber, ErrorMessage = "Please enter valid phone number")]
public string BusinessTelephoneNumber { get; set; }
[Display(Name="Cell")]
public string MobileTelephoneNumber { get; set; }
[Display(Name="Fax")]
public string BusinessFaxNumber { get; set; }
}