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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:33:02+00:00 2026-06-15T04:33:02+00:00

I`m trying to pass the Html.Textbox value in the javascript url but it is

  • 0

I`m trying to pass the Html.Textbox value in the javascript url but it is giving an error.

Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /WebProduct/Add/1

Below is my view class. from which i`m passing values to my controller.

Edited

 @model IEnumerable<DatabaseService_WebAPI.Models.ProductType>

@{
    ViewBag.Title = "Tablets";

    <script type="text/javascript">

        $(function () {
            $('#edit').click(function () {
                var name = $('#quantity').val();
                this.href = this.href + '&quantity=' + encodeURIComponent(name);
            });
        });

    </script>

}

<h2>Tablets</h2>
@using (Html.BeginForm("Add", "WebProduct", FormMethod.Post))
{
    @Html.ValidationSummary(true)

    <table>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Price)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Batch)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Expiry)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Quantity)
            </th>
        </tr>

        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>

                <td>
                    @Html.DisplayFor(modelItem => item.Price)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Batch)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Expiry)
                </td>
                <td>
                    @Html.TextBox("quantity")
                </td>
                <td>
                    @Html.ActionLink("Add", "Add", new { name = item.Name, type = item.Type }, new { id = "edit" })

                </td>
            </tr>
        }

    </table>
}
<div>
    @Html.ActionLink("Back to List", "Create")
</div>

And its my controller method in which I`m passing the values.

[HttpPost]
        public ActionResult Add(string quantity, string name, string type)
        {

            Product product = new Product();
            if (type=="Tablet")
            {

                //string order = type.Name + " " + type.Quantity;
                LocalDB tobj = ldb.LocalDBs.Single(s => s.User == User.Identity.Name);

                product.city = tobj.City;
                product.OrderDate = DateTime.Now.Date.ToShortDateString();
                product.ShopName = tobj.ShopName;
                product.User = tobj.User;
                //product.OrderDetail = order;

                db.Products.Add(product);
                db.SaveChanges();

                return RedirectToAction("TypeT", "WebProduct");
            }
            else if (type == "Syrup")
            {
                //string order = type.Name + " " + type.Quantity;
                LocalDB tobj = ldb.LocalDBs.Single(s => s.User == User.Identity.Name);
                product.city = tobj.City;
                product.OrderDate = DateTime.Now.Date.ToShortDateString();
                product.ShopName = tobj.ShopName;
                product.User = tobj.User;
             //   product.OrderDetail = order;

                db.Products.Add(product);
                db.SaveChanges();

                return RedirectToAction("TypeS", "WebProduct");
            }
            else
            {

              //  string order = type.Name + " " + type.Quantity;
                LocalDB tobj = ldb.LocalDBs.Single(s => s.User == User.Identity.Name);
                product.city = tobj.City;
                product.OrderDate = DateTime.Now.Date.ToShortDateString();
                product.ShopName = tobj.ShopName;
                product.User = tobj.User;
             //   product.OrderDetail = order;

                db.Products.Add(product);
                db.SaveChanges();

                return RedirectToAction("TypeC", "WebProduct");
            }

            return View();
        }

At this point i don’t want to use button options. because i want to send database record and user’s input to my controller`s method.

  • 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-15T04:33:04+00:00Added an answer on June 15, 2026 at 4:33 am

    My understanding is that your

    this.href == localhost:3325/WebProduct/Add?name=Panadol&type=Tablet
    

    if that is correct then the following should work

    $(function () 
     {
        $('#edit').click(function () 
        {
            var name = $('#quantity').val();
    
            var href = this.href;
            var splitHalfUrl = href.split('?');
            var splitQueryString = splitHalfUrl[1].split('&');
            window.location = "/WebProduct/Add?" + "quantity=" + encodeURIComponent(name) // Quantity
                                                "&" + splitQueryString[0] +   // Name
                                                "&" + splitQueryString[1];    // Type
    
         });
       });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pass a value from html to a function but when I
I'm using Html.BeginForm and trying to pass the supplied value of the textBox archName
I am trying to pass Eval to Html.RenderPartial inside ASP.NET Repeater but it does
I'm trying to pass a link_to block with html but can't get it. I
I am trying to pass a number to my JavaScript function, but actually a
I'm trying to pass a value from a select input control on an HTML
I am trying to pass a Hexadecimal color value from objectiveC to Javascript. I
Am trying to pass a argument in jquery html pop up.But am not able
I'm trying to pass a parameter from php into my javascript function inside html.
Trying to pass data to the server but it keeps returning a Parameter Missing

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.