15,888,008 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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>
<!--
Mani89
9-Jun-14 1:26am
View
Deleted
Hi,
Thanks for the immediate reply.I have tried that also but not working.Even I have tried giving the url action in ajax success condition but that also dint work.When I checked using break point the control goes back to the Add Member action result after successfully saving the data.Any solution to prevent going to that action result?
Mani89
19-Mar-14 5:31am
View
Thank you..will check and let you know..
Mani89
19-Mar-14 4:14am
View
yeah..can we do that in silverlight web application???if so can you provide me with some link...
Thanks in advance...
Show More