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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:18:35+00:00 2026-05-30T11:18:35+00:00

In my .cshtml, I’m painting some data. Then I have a repy textbox and

  • 0

In my .cshtml, I’m painting some data. Then I have a repy textbox and a button for people to reply to a customer service thread.

@using (Html.BeginForm("Update", "CustomerServiceMessage", FormMethod.Post, new { id = 0 }))
    ...
}

When I submit, I don’t get 0 when it hits my Update actionmethod, I get the id of the parent Service message I painted above the reply box. So it’s like an email/forum thread but even though I hard code the = 0 the Update method is getting an Id of the parent message that I painted on the screen (rendered).

Can’t figure out why.

  • 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-30T11:18:37+00:00Added an answer on May 30, 2026 at 11:18 am

    When I submit, I don’t get 0 when it hits my Update action method

    That’s normal, you never send this id to your server. You just used the wrong overload of the Html.BeginForm helper:

    @using (Html.BeginForm(
        "Update",                        // actionName
        "CustomerServiceMessage",        // controllerName
        FormMethod.Post,                 // method
        new { id = 0 }                   // htmlAttributes
    ))
    {
        ...    
    }
    

    and you ended up with the following markup (assuming default routes):

    <form id="0" method="post" action="/CustomerServiceMessage/Update">
        ...
    </form>
    

    See the problem?

    And here’s the correct overload:

    @using (Html.BeginForm(
        "Update",                        // actionName
        "CustomerServiceMessage",        // controllerName
        new { id = 0 },                  // routeValues
        FormMethod.Post,                 // method
        new { @class = "foo" }           // htmlAttributes
    ))
    {
        ...    
    }
    

    which generates (assuming default routes):

    <form method="post" action="/CustomerServiceMessage/Update/0">
        ...
    </form>
    

    Now, you will get your id=0 inside the corresponding controller action.

    By the way you could make your code more readable and avoid this kind of mistakes by using C# 4.0 named parameters:

    @using (Html.BeginForm(
        actionName: "Update", 
        controllerName: "CustomerServiceMessage", 
        routeValues: new { id = 0 }, 
        method: FormMethod.Post,
        htmlAttributes: new { @class = "foo" }
    ))
    {
        ...    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this _Layout.cshtml <body> <div id=wrapper> <div id=header-wrapper> <div id=header> <div id=logo> //SOME
I have the following in my _Layout.cshtml: <title>@ViewData[PageTitle]</title> I then have a Child Action
I have a _Layout.cshtml page which I've used to include all master page styling.
I have an code segment of view .cshtml page like : @Html.ActionLink(Add Charts of
I have the following code in a CSHTML razor page: @{ var sort =
Suppose I have a parent.cshtml view with a parentModel, and a child.cshtml view with
I have a list of objects which uses paging in my home > index.cshtml.
I have a System.Web.Mvc.RazorView object which is strongly typed when in cshtml. Can I
In the file FirstView.cshtml I have an event - clicking to a cell of
In Index.cshtml I have the following: @{ Html.Telerik().Grid<hekomaseru.Models.testdbEntities1>(testtable) .Name(grid1) .Pageable() .Sortable() .Filterable() .Groupable() .Render();

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.