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 7590789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:29:33+00:00 2026-05-30T20:29:33+00:00

Using Visual Studio 2010, MVC project When my form is submitted (currently via javascript,

  • 0

Using Visual Studio 2010, MVC project
When my form is submitted (currently via javascript, but same results with a submit button), the action is getting an empty model with both of the fields in it being zero instead of containing the value I entered into the textbox. The Request object does contain the correct name/value pair in the Form collection.

Model values going the other way work fine – so based on my [HttpGet] CallDisplayHome() action, the form loads with the textbox value being 1.

If anyone has a clue as to why it would not work coming back via POST, I would sure appreciate it.

Model being used:

namespace TCSWeb.Models
{
    public class CallDisplayModel
    {
        public int SelectedRowIndex;
        public int SelectedLineID;
    }
}

View:

@model TCSWeb.Models.CallDisplayModel

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<body>
/*
There a Jscript datatable here and a bunch of scripts for working with it in the header     I am skipping because I am hoping they are not relevant
*/

    <div>
    @using (Html.BeginForm("Testing", "CallDisplay", FormMethod.Post, new { name = "submitSelLine" }))
    {
        @Html.TextBoxFor(m => m.SelectedLineID)    
        <p>
            <input type="submit" value="Log On" />
        </p>        
    }    
    </div>    
    <button onclick="SubmitSelCallRecord()">@LangRes.Strings.calldisplay_opencallrecord</button>

My controller actions:

    [HttpGet]
    public ActionResult CallDisplayHome()
    {
        TCSWeb.Models.CallDisplayModel temper = new CallDisplayModel();
        temper.SelectedLineID = 1;
        temper.SelectedRowIndex = 1;
        return View(temper);
    }

[HttpPost]
public ActionResult Testing(TCSWeb.Models.CallDisplayModel cdmodel)
{
    return RedirectToAction("CallDisplayHome"); //breaking here, cmodel has zero for selectedlineid
}
  • 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-30T20:29:34+00:00Added an answer on May 30, 2026 at 8:29 pm

    You need to declare your CallDisplayModel variables as properties:

    public int SelectedRowIndex { get; set; }
    
    [Required]
    public int SelectedLineID { get; set; }
    

    You can also add a little bit of validation to make sure that the user provides the correct information.

    Change your post method to the following:

    [HttpPost]
    public ActionResult Testing(TCSWeb.Models.CallDisplayModel temper)
    {
        //check if valid
        if(ModelState.IsValid)
        {
            //success!
            return RedirectToAction("CallDisplayHome"); 
        }
        //update error! redisplay form
        return View("CallDisplayHome", temper);
    
    }
    

    And display the errors in your view like so:

    @Html.ValidationMessageFor(m => m.SelectedLineID)
    @Html.TextBoxFor(m => m.SelectedLineID) 
    

    I’m unsure what your submitSelCallRecord button is doing, as it is referencing the javascript that was omitted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create a ASP.net MVC 4 project by using Visual Studio 2010 IDE. I
I am using Visual Studio 2010 for an MVC website project. I have an
I have a MVC 2 project, using Entity Framework, in Visual Studio 2010 and
I am using ASP.NET MVC 2 in Visual Studio 2010. In my project I
I have a ASP.NET MVC 2 project on Visual Studio 2010. I want to
Setup: I am using MVC 3, EF 4.1, Visual Studio 2010 SP1 with Power
I am using Visual Studio 2010 / ASP.net MVC 3 with the Razor View
I'm using Visual Studio 2010 RC and MVC 2 projects appear in File |
I'm trying to debug MVC source code in Visual Studio 2010 using the Microsoft
I am using Visual Studio 2010 RC1. I define a resource Brush2 in app.xaml_:

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.