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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:41:10+00:00 2026-06-17T18:41:10+00:00

I have a ASP.NET Razor view which binds to string. Its very simple: @model

  • 0

I have a ASP.NET Razor view which binds to string. Its very simple:

@model string
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

Hello, @Model

@using(Html.BeginForm())
{
    <fieldset>
        <label for="name" style="color: whitesmoke">Name:</label>    
        <input type="text" id="name"/>
        <br/>
        <input type="submit" value="Submit"/>
    </fieldset>
}

And a simple controller:

[HttpGet]
public ActionResult Index()
{
    object model = "foo";
    return View(model);
}

private string name;
[HttpPost]
public ActionResult Index(string name)
{
    return View();
}

When I push the submit button, the Index Post action result triggers, but the ‘string name’ parameter is null. Isn’t Razor smart enough to automatically bind this property to my controller from the view because the input id matches the name of the param on the controller? If not, how do I bind this? I know with a model with properties I can use Html.HiddenFor(m => m.Foo), but since there’s no properties, I don’t know how to call this method properly.. I can set it properly calling Html.Hidden(“name”,”foo”), but I don’t know how to pass a the value here. I know I can use jquery call such as:

 @Html.Hidden("name", "$('input[id=name]').val())"); 

This literally sends the jquery string to the controller as the value… I’m not sure what to do at this point. Thanks!

  • 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-06-17T18:41:11+00:00Added an answer on June 17, 2026 at 6:41 pm

    It is smart enough to bind the property, just give your input a name which matches with the action parameter:

    <input type="text" id="name" name="name" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

'm using ASP.NET MVC 3 with Razor views. I have a partial view which
I have a Asp.net MVC application(using Razor View) in which i am using Html.Textboxfor
I am working in asp.net MVC 3 application with Razor view. I have string
I am developing an ASP.Net MVC 3 Web application using Razor Views. I have
I have an odd problem with one of my Razor views in an ASP.NET
I'm having an odd problem with asp.net MVC razor view. I want my model
In ASP.NET MVC there is Model, View and Controller. MODEL represents entities which are
I have an href in my asp.net MVC3 Razor view and I want to
I am working on a project which adopted ASP.NET MVC3(Razor) tech. Now, I have
I have the following in my ASP.Net MVC 3 Razor View @foreach (var item

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.