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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:37:36+00:00 2026-05-24T10:37:36+00:00

In the following code, the get action returns a betting card for a given

  • 0

In the following code, the get action returns a betting card for a given race date, and the post I use the post action to transform properties of the bound model to route values for the get action.

Essential aspects of the Details View:

@using (Html.BeginForm("Upload", "BettingCard",
                         FormMethod.Post, new { id = "uploadForm", enctype = "multipart/form-data" }))
{ 
    @Html.ValidationSummary(true, "The upload was unsuccessful.  The following error(s) occurred: ")
    <div id="date-selector">
        <div id="ymd">
            @Html.LabelFor(model => model.RaceDate)
            @Html.DropDownListFor(model => model.RaceDay, Model.YmdLists.Days)
            &nbsp; @Html.DropDownListFor(model => model.RaceMonth, Model.YmdLists.Months)
            &nbsp; @Html.DropDownListFor(model => model.RaceYear, Model.YmdLists.Years)
            &nbsp;&nbsp;<input type="submit" value="Upload for this date" />
        </div>
    </div>
    @Html.Telerik().Upload().Name("UploadedFiles")
}

Essential aspects of the controller code:

[HttpGet]
public ActionResult Details(int year, int month, int day) {
    var model = new BettingCardModel
                    {
                        ResultMessage = "No betting card was located for the selected date."
                    };
    DateTime passedDate;
    if (!DateTimeHelper.TrySetDmy(year, month, day, out passedDate)) {         
        ModelState.AddModelError("", "One or more values do not represent a valid date.");
        return View(model);
    }
    model.RaceDate = passedDate;
    var bettingCard = _bettingCardService.GetByRaceDate(passedDate);
    model.MapFromEntity(bettingCard);
    return View(model);
}

[HttpPost]
public ActionResult Details(BettingCardModel model)
{
    return RedirectToAction("Details", new { year = model.RaceYear, month = model.RaceMonth, day = model.RaceDay });
}

A good deal of the above code is experimental and diagnostic, so I’d like to avoid getting into a review of code that works, and rather concentrate on what I need to achieve. In the Details view I only need one ‘command’, being ‘Display for Date’, so I get off easily by using the submit button and the http post takes care of model binding. However, in the Upload view, I need two commands, being ‘Display for Date’ and ‘Upload for Date’, so I would like to make the ‘Display for Date’ operate strictly with the get actions, and only use a post action to submit an uploaded betting card for the date.

My problem is that when I make the ‘Display for Date’ command use an ActionLink instead of a submit, using model.RaceDay etc. as routing values, the URL parameters passed to Details all still contain their initial values, not values set by the user in the dropdowns. It seems the model binding code (whatever that may be) is not invoked for action links. What could I do here to avoid need a post just to do that binding?

I realise this probably not a direct model binding issue, but I don’t know how else to express my question. When elements ‘bound’ to model properties are rendered, they have a bit more on their side than a simple input, say, and some basic styling, but something is ‘built’ around that input with lots of metadata. I would like some way to use that metadata to map to a URL when a get link on the page is clicked.

  • 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-24T10:37:37+00:00Added an answer on May 24, 2026 at 10:37 am

    The problem you’re having is that all of the model data and metadata is generated on the server dynamically and given to the client as static content. The binding is only aware of a change to the Model once it is submitted to the Server. All of that model metadata is static on the client side, using pure .NET it will have no way to know when a user changes a value in the drop-down to also change that value in a static anchor tag, which is what the ActionLink renders to. The answer is to use javascript. There are many many way to accomplish what you’re trying to do through javascript. You could potentially write a custom HtmlHelper class to generate the javascript for you. However if you don’t want to use javascript then you will HAVE to do a post to get the data the user selected to the Server.

    If you’re trying to avoid having to re-write code then you can create a partial view for the contents of the form and embed that in two separate views. Another thing you could try is to detect which button was pushed by having two submit buttons with the same name like so:

        <input type="submit" name="command" value="Update" />
        <input type="submit" name="command" value="Display" />
    

    Then in your Controller in the [HttpPost] action you can detect which was pushed via the Request.Forms like this:

    [HttpPost]
    public ActionResult Details(BettingCardModel model)
    {
        if (Request.Forms["command"].Equals("Display"))
        {
            return RedirectToAction("Details", new { year = model.RaceYear, month = model.RaceMonth, day = model.RaceDay });
        }
    
        // Do your update code here...
        return // Whatever it is you return for update.
    }
    

    hopefully this helps you.

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

Sidebar

Related Questions

The following code is in the /Courses/Detail action: [AcceptVerbs(GET)] public ActionResult Detail(int id) {
i have the following code def get(self): date = datetime.date.today() loc_query = Location.all() last_cursor
In my view I use the following code to get an image from my
Why does the following code get the runtime error: Members of the Triggers collection
I have the following code: // GET: /PlayRoundHole/Create public ActionResult Create(int id) { DB
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
I tried the following code to get an alert upon closing a browser window:
In the following code I get a segmentation fault: Set *getpar() {...} char function(...)
When running the following code I get no output but I cannot work out
I'm using the following code to get the members of a group on my

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.