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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:18:21+00:00 2026-06-01T05:18:21+00:00

I want to pass the parameter which is rentalPeriod using Html.BeginForm. Currently, I put

  • 0

I want to pass the parameter which is rentalPeriod using Html.BeginForm.
Currently, I put just text in Details.cshtml.
If I want to pass the rentalPeriod such as 3, 7, 14 as a number, what do I have to do?
Do I have to use hiddenfield or a function?
I don’t know how to pass the parameter to my other method which is AddToCart method.
Please let me know how to pass the value of the number.
Thanks.

Details.cshtml.

<td>
        Rental Period: <br />
        @using (Html.BeginForm("AddToCart", "ShoppingCart", new { id = Model.productId }, FormMethod.Post))
        { 
            <div class="display-label">
            @Html.RadioButtonFor(model => model.price, Model.threeDayPrice) 
            //I put just text in here '3 day' How can I write this number, '3'?
            //do I have to use hiddenfield? or other functions?
            3 day: £@Model.threeDayPrice
            </div>
            <div class="display-label">
            @Html.RadioButtonFor(model => model.price, Model.aWeekPrice)
            1 week: £@Model.aWeekPrice 
            </div>
            <div class="display-label">
            @Html.RadioButtonFor(model => model.price, @Model.twoWeekPrice)
            2 week: £@Model.twoWeekPrice 
            </div>
            <div class="display-label">
            @Html.RadioButtonFor(model => model.price, @Model.aMonthPrice)
            1 month: £@Model.aMonthPrice 
            </div>
            <div class="display-label">
            @Html.RadioButtonFor(model => model.price, @Model.threeMonthPrice)
            3 month: £@Model.threeMonthPrice 
            </div>
            <div class="display-label">
            @Html.RadioButtonFor(model => model.price, @Model.sixMonthPrice)
            6 month: £@Model.sixMonthPrice 
            </div>
            <br />
            <input type="submit" class="button" value="Add to cart" style="margin-left:0px; width:90px;"/>
        }      
    </td>

ShoppingCart controller in AddToCart method.

//How to pass the parameter here.
[HttpPost]
    public ActionResult AddToCart(int id, FormCollection col)
    {
        var addedProduct = db.Product
            .Single(product => product.productId == id);
        decimal priceValue = Convert.ToDecimal(col["price"]);

        // Retrieve the product from the database
        // Add it to the shopping cart
        var cart = ShoppingCart.GetCart(this.HttpContext);

        cart.AddToCart(addedProduct);

        // Go back to the main store page for more shopping
        return RedirectToAction("Index", new { @priceValue = priceValue });
    }
  • 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-01T05:18:22+00:00Added an answer on June 1, 2026 at 5:18 am

    I strongly suggest that you use View Models rather than relying on the FormsCollection. However, yes.. in your case you can just use a hidden field to store the item, then you pull it out of the FormsCollection.

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

Sidebar

Related Questions

I have this class which I want to pass around Windows as LPARAM parameter.
I want pass a parameter of javascript functiona which is a string. This javascript
I want to pass an enum value as command parameter in WPF, using something
HTML: I want to pass the value from the gsearch to the q parameter.
I pass parameter with url called var which is containing value 'event'. I want
I have an xml document which i want to pass as a parameter to
I want to pass a parameter to the index action, but the I'm only
I want to pass two parameter to nativeProcess. While i am running exe file
I have following code and i want to pass additional parameter in JSON.getJSONfromURL() method
I have a NameValueCollection with parameter. I want to pass all parameter in SqlCommand

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.