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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:32:47+00:00 2026-05-27T12:32:47+00:00

Good day all, what would be the best way to read a value from

  • 0

Good day all, what would be the best way to read a value from a text box in a view and to cast it into an integer in the corresponding controller?

View:

@{
    ViewBag.Title = "Index";
}

<h2>Administration</h2>

<p>
    Page number:
    @Html.TextBox("pageNumber")

    @Html.ActionLink("Fetch stats", "FetchStats", "Admin", null,
             new { @style = "text-transform:capitalize;" })


</p>

Controller:

public ActionResult FetchStats(int pageNumber)
    {
    CurrentGameNumber = pageNumber;
    [...]

    return View("Index");

}
  • 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-27T12:32:47+00:00Added an answer on May 27, 2026 at 12:32 pm

    Here’s a simple example. We’ll add a textbox named “PageNumber” to the form within our View to post data to our FetchStats action method. MVC will take care of all of the plumbing, instantiating the controller and calling the FetchStats action method while provide pageNumber as an integer.

    View

    @{
        ViewBag.Title = "Index";
    }
    
    <h2>Administration</h2>
    
    @using (Html.BeginForm("FetchStats", "Admin")) {    
    <p>
        Page number:
        @Html.TextBox("pageNumber")
    
        <input type="submit" value="Fetch Stats" />
    </p>
    }
    

    Action Method

    [HttpPost]
    public ActionResult FetchStats(int pageNumber)
    {
        CurrentGameNumber = pageNumber;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day all I have the following question: I would like to use Chart
Good day to all. I have this setup: One page with text/whatever, that also
Good Day All, I want to add text floating in my wireframe plot and
Good day all, i have a load of images i want to display from
Good Day All we are trying to do is inside a trigger make sure
Good day all, first of all, what am trying to do is have an
Good day to all, I have the following problem I have to convert the
Good day everyone. I have been having the same problem all day at work
Good morning all, After a day of googling, I’m at a loss. I decided
Good day all, I am having some trouble with image permissions. I am loading

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.