Click here to Skip to main content
15,888,008 members

Comments by Mani89 (Top 8 by date)

Mani89 30-Jan-15 1:22am View    
thank u ravi sharma...
Mani89 17-Jun-14 6:04am View    
Hi sampath,
Thanks for the immediate reply.I have tried the solution you said but now its going to actionresult for the index page,instead of going to the url mentioned.Then I tried removing "contentType: "application/json" for that it wil go to the url but null value for the model.Can you help me??
Mani89 9-Jun-14 4:38am View    
okay sorry...will improve the question...
Mani89 9-Jun-14 3:32am View    
Hi Smruti,
Thanks for the immediate reply.I have tried that but that is also not working
Instead of going to the index in AdminHome it's going to index in the same controller. Please refer to the updated question..
Mani89 9-Jun-14 3:27am View    
Deleted
Hi Smruti,
Thanks for the immediate reply.I have tried that but that is also not working
Controller Code
<pre lang="c#">public ActionResult Register(MemberDetail user)
{

using (Election_TVM context = new Election_TVM())
{

context.MemberDetails.Add(user);
context.SaveChanges();
//return Json("User registered successfully", JsonRequestBehavior.AllowGet);
RedirectToAction("Index", "AdminHome");

}

}</pre>
After execution its going to this action result
<pre lang="c#"> public ActionResult Index(string hfDistrict, string hfArea, string hfLocal, string hfBranch, int? hfBranchId)
{
ViewBag.DistrictId = hfDistrict;
ViewBag.AreaId = hfArea;
ViewBag.LocalId = hfLocal;
ViewBag.Branch = hfBranch;
ViewBag.BranchId = hfBranchId;
return View();

}</pre>
HTML Page
<pre lang="HTML">
@model ElectionCampaign.Models.MemberDetail
@{
Layout = "~/Views/Shared/_Master.cshtml";
}
<script type="text/javascript">
var RDMinority;
var RDGender;
$(document).ready(function () {



$(document).on('click', '#btnCancel', function () {
window.location.href = "../AdminHome/Index";
});
$("input:radio[name=RadioGender]").click(function () {
RDGender = $(this).val();

});
$("input:radio[name=RadioMinority]").click(function () {
RDMinority = $(this).val();


});
$(document).on('click', '#btnSubmit', function () {

if (validation() == false) {
return false;

}
else {
SaveInfo();

}

});
});
function validation() {

var Result = false;
if ($("#txtName").val() == "") {
Result = true;

$("#lblName").show()
}
else { $("#lblName").hide() }
if ($("#txtAge").val() == "") {
Result = true;

$("#lblAge").show()
}
else { $("#lblAge").hide() }
if ($("#ddlMartial").val() == "") {
Result = true;

$("#lblMstatus").show()
}
else { $("#lblMstatus").hide() }
if ($("#ddlMembershipYear").val() == "") {
Result = true;

$("#lblYear").show()
}
else { $("#lblYear").hide() }
if ($("#ddlMembershipType").val() == "") {
Result = true;

$("#lblType").show()
}
else { $("#lblType").hide() }

if (Result == true) { return false }
}
function SaveInfo() {
var source = ({
'Name': $("#txtName").val(),
'Age': $("#txtAge").val(),
'Gender': RDGender,
'MartialStatus': $("#ddlMartial").val(),
'BranchId': '@ViewBag.BranchId',
'Education': $("#ddlEducation").val(),
'Occupation': $("#ddlOccupation").val(),
'Caste': $("#ddlCaste").val(),
'Minority': RDMinority,
'MonthlyIncome': $("#txtIncome").val(),
'JoiningYear': $("#ddlMembershipYear").val(),
'MembershipType': $("#ddlMembershipType").val(),
'Organisation': $("#ddlOrganization option:selected").text(),
'OccupationBased': $("#txtOcupationClass").val(),
'Levy': $("#txtLevi").val()

});

$.ajax({
type: "POST",
url: '@Url.Action("Register", "AddMember")',
data: source,
success: function (data) {
//$('#lblMsg').html(data);
var url = "@Url.Action("Index", "AdminHome")";
window.location.href = url;
alert(url);
},
error: function (error) {
$('#lblMsg').html(error);
}
});
}
</script>


<!--