Click here to Skip to main content
15,886,110 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Html helper in c# mvc app Pin
e$heldon19-Jun-17 9:10
e$heldon19-Jun-17 9:10 
AnswerRe: Html helper in c# mvc app Pin
John C Rayan19-Jun-17 3:26
professionalJohn C Rayan19-Jun-17 3:26 
GeneralRe: Html helper in c# mvc app Pin
e$heldon19-Jun-17 9:13
e$heldon19-Jun-17 9:13 
QuestionCall Default View From Controller Pin
Kevin Marois16-Jun-17 7:57
professionalKevin Marois16-Jun-17 7:57 
AnswerRe: Call Default View From Controller Pin
Richard Deeming16-Jun-17 8:40
mveRichard Deeming16-Jun-17 8:40 
GeneralRe: Call Default View From Controller Pin
Kevin Marois16-Jun-17 9:14
professionalKevin Marois16-Jun-17 9:14 
GeneralRe: Call Default View From Controller Pin
Kevin Marois19-Jun-17 4:03
professionalKevin Marois19-Jun-17 4:03 
QuestionTrying to save some values from html to Database by using the WebApi HttpPost method Pin
indian14316-Jun-17 7:53
indian14316-Jun-17 7:53 
Hi all,

I am little new to MVC and WebApi, I am here trying to post values of html form to a HttpPost method of Web Api, here how I am using it
$("#btnSave").click(function () {
    var defaultText = $("#defaultText").val();
    var txtLanId = $("#txtLanId").val();
    var txtLast = $("#txtLast").val();
    var txtFirst = $("#txtFirst").val();
    var txtEmployeeId = $("#txtEmployeeId").val();
    var txtEmail = $("#txtEmail").val();

    var dtFieldHireDate = $("#dtFieldHireDate").val();
    var dtFieldRehireDate = $("#dtFieldRehireDate").val();
    var lbxApplicationGroup = $("#lbxApplicationGroup").val();
    var lbxReportPack = $("#lbxReportPack").val();

    alert(dtFieldHireDate);
    alert(dtFieldRehireDate);
    alert(lbxApplicationGroup);
    alert(lbxReportPack);

    $.ajax({
url: "/api/EmployeeAPI",
type: "Post",
data: JSON.stringify([defaultText, txtLanId, txtLast, txtFirst, txtEmployeeId, txtEmail, dtFieldHireDate, dtFieldRehireDate, lbxApplicationGroup, lbxReportPack]),
contentType: 'application/json; charset=utf-8',
success: function (data) { },
error: function () { alert('error'); }
    });
});
When I am trying to retrieve those values in the Web Api method, I am getting empty strings, I am not sure what's going wrong here, but any help is going to be very helpful, thanks in advance.
[System.Web.Http.HttpPost]
public string PostAction(System.Net.Http.Formatting.FormDataCollection form)
{
    string retValues;   
    retValues = form.Get("txtLast") + form.Get("txtLanId");

    return retValues;
}

Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."
AnswerRe: Trying to save some values from html to Database by using the WebApi HttpPost method Pin
Richard Deeming16-Jun-17 8:30
mveRichard Deeming16-Jun-17 8:30 
GeneralRe: Trying to save some values from html to Database by using the WebApi HttpPost method Pin
indian14319-Jun-17 9:56
indian14319-Jun-17 9:56 
GeneralRe: Trying to save some values from html to Database by using the WebApi HttpPost method Pin
Richard Deeming19-Jun-17 11:37
mveRichard Deeming19-Jun-17 11:37 
QuestionRegarding querystring Pin
Member 1324809013-Jun-17 1:17
Member 1324809013-Jun-17 1:17 
SuggestionRe: Regarding querystring Pin
Richard MacCutchan13-Jun-17 5:07
mveRichard MacCutchan13-Jun-17 5:07 
AnswerRe: Regarding querystring Pin
ZurdoDev15-Jun-17 2:56
professionalZurdoDev15-Jun-17 2:56 
AnswerRe: Regarding querystring Pin
John C Rayan19-Jun-17 3:34
professionalJohn C Rayan19-Jun-17 3:34 
QuestionLock down the URL of an application for single device Pin
Schatak12-Jun-17 22:14
professionalSchatak12-Jun-17 22:14 
AnswerRe: Lock down the URL of an application for single device Pin
Afzaal Ahmad Zeeshan12-Jun-17 22:58
professionalAfzaal Ahmad Zeeshan12-Jun-17 22:58 
AnswerRe: Lock down the URL of an application for single device Pin
Deepak Vasudevan15-Jun-17 0:52
Deepak Vasudevan15-Jun-17 0:52 
GeneralRe: Lock down the URL of an application for single device Pin
Richard Deeming15-Jun-17 1:45
mveRichard Deeming15-Jun-17 1:45 
QuestionProgramatically click a button using http POST request Pin
Prasadaknair10-Jun-17 8:15
Prasadaknair10-Jun-17 8:15 
Answer[Repost] Programatically click a button using http POST request Pin
Richard MacCutchan10-Jun-17 9:16
mveRichard MacCutchan10-Jun-17 9:16 
QuestionHow to run jquery in visual studio 2008 asp.net web application project Pin
HedwigO10-Jun-17 1:36
HedwigO10-Jun-17 1:36 
AnswerRe: How to run jquery in visual studio 2008 asp.net web application project Pin
F-ES Sitecore11-Jun-17 23:11
professionalF-ES Sitecore11-Jun-17 23:11 
GeneralRe: How to run jquery in visual studio 2008 asp.net web application project Pin
HedwigO13-Jun-17 4:56
HedwigO13-Jun-17 4:56 
GeneralRe: How to run jquery in visual studio 2008 asp.net web application project Pin
Richard Deeming13-Jun-17 5:04
mveRichard Deeming13-Jun-17 5:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.