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

  • SEARCH
  • Home
  • 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

There are all sorts of advantages to using Emacs, but for someone comfortable with
First of all there is a partial question regarding this, but it is not
Hi All is there any way to locally define a variable in a function
I'm sure you have all been there, you take on a project where there
What are some guidelines for maintaining responsible session security with PHP? There's information all
There are many things that all programmers should know, but I am particularly interested
Is there anyway to combine all resources into a single exe file such as
Are there any implementations of all the nifty Selenium on Rails methods like wait_for_visible
Is there a list describing all of the data_type parameters you can use in
Is there a way at all of altering the clipboard of the user via

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.