Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:48:58+00:00 2026-05-25T14:48:58+00:00

There are all kinds of posts out there about getting the input fields off

  • 0

There are all kinds of posts out there about getting the input fields off a form/div and sending them to your server side controller. What I am not clear on is how to accept the input at the controller.

I have tried various methods:

function SendEMail( vThis )
{
    var vInput = $("#idEMailFields *").serializeArray();

    $.ajax({
        url: '@Url.Action( "SendEMail", "TournMaint")',
        data: JSON.stringify(vInput),
        type: 'POST',
        contentType: 'application/json; charset=utf-8;',
        dataType: 'json',
        success: function (response)
        {
            $("#idEMailResponse").html(response);
            return;
        },
        error: function( xhr, status, error )
        {
            debugger;
            var verr = xhr.status + "\r\n" + status + "\r\n" + error; 
            alert( verr );
        }   
    });
}

where the controller looks like:

[HttpPost]
public JsonResult SendEMail( CNameValue [] inputs )
{
    String sView = "EMail messages queued"; 
    return Json( sView, JsonRequestBehavior.AllowGet );
}

The CNameValue class is my own creation since I didn’t find a standard that would do the same thing. There should be a standard dictionary class that would pick the parameters up by name?? My question is how should this be done??

The Second variation:

function SendEMail( vThis )
{
    var params = {};
    var v1 = $("#idEMailFields input[name=EMailAddressing], #idEMailFields input[type=hidden],#idEMailFields textarea");
    $(v1).each( function(index)
    {
        params[this.name]=this.value;
    });
    $.ajax({
        url: '@Url.Action( "SendEMail", "TournMaint")',
        data: JSON.stringify(params),
        type: 'POST',
        contentType: 'application/json; charset=utf-8;',
        dataType: 'json',
        success: function (response)
        {
            debugger;
            return;
        },
        error: function (x)
        {
            debugger;
            alert(x.status);
        }   
    });
}

Where the controller looks like:

[HttpPost]
public JsonResult SendEMail( Int32 TournamentId, String EMailText, String EMailAddressing )
{
    String sView = "return something usefull";
    return Json( sView, JsonRequestBehavior.AllowGet );
}

This is not a bad way to move data to the sever but it is susceptible to changes in the razor markup causing the controller to blow. I know that you never get away from that problem but reducing the possibility is a thought.

What is the best way to get screen data to the server side controller?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:48:59+00:00Added an answer on May 25, 2026 at 2:48 pm

    if you are using strongly typed views then all you have to do is

     $.ajax({
            url: '@Url.Action( "SendEMail", "TournMaint")',
            data: {model:JSON.stringify(vInput)},
            type: 'POST',
       ...
    

    and the controller looks like

    [HttpPost]
    public JsonResult SendEMail( CNameValue model )
    {
        String prop = model.YourModelProperty; 
    

    also you can use the form collection

     $.ajax({
            url: '@Url.Action( "SendEMail", "TournMaint")',
            data: {col :$("Formid").serialize()},
            type: 'POST',
       ...
    

    and the controller looks like

    [HttpPost]
    public JsonResult SendEMail( FormCollection col )
    {
        String prop = col.Get("FormFieldName"); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We all know that most applications out there assume class names to follow the
First of all there is probably a question like this already but i couldn't
Hi All is there any way to locally define a variable in a function
I created a virtualenv in my django app folder, and there I installed all
There are many things that all programmers should know, but I am particularly interested
There is a rewrite rule ensuring that all URL's head to index.php and maintain
What all possible support is there from open source world for building web based
There is any ways to listing all main directories present in php server(may it
There is a term named API communication all over around. Can anybody tell me
Assuming there are buttons with all the letters from the alphabet set as Text.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.