locked
how can I pass argument in anchor tag href RRS feed

  • Question

  • User-1355965324 posted

    Please can you help  me how call the argument depotid, departmentid, employeeid  to the href href="/Home/UpdateClockEntry"    <a class="btn. Please help

    <div class="pull-right" style="font-family:sans-serif">
     <a   class="btn btn-primary form-control" href="/Home/UpdateClockEntry"   data-ajax="true" data-ajax-mode="replace" data-ajax-update="#content" data-toggle="tooltip" title="New Clocking Entry"><span class="control-label-left padding-left-ten">Add New Clocking Record</span></a>
    </div>
    
    <div class="controls col-sm-9">
                                    <select id="depotid" class="form-control" asp-for="DepotNo" asp-items="@ViewBag.UserDepots"  ></select>
                                    <span asp-validation-for="DepotNo" class="text-danger"></span>
    </div>
    
    <div class="controls col-sm-9">
                                    <select id="departmentid" class="form-control" asp-for="DepartmentID" asp-items="@ViewBag.UserDepartments" data-role="select"  ></select>
                                    <span asp-validation-for="DepartmentID" class="text-danger"></span>
    </div>
    
     <div class="controls col-sm-9">
                                    <select id="employeeid" class="form-control" asp-for="EmployeeID" asp-items="@ViewBag.Employees"   class="text-danger"></span>
    </div>
    
    
    
    Controller
    public IActionResult UpdateClockEntry(int depotno,int department,int employeeid)
    {
       return view()
    }

    Thursday, March 5, 2020 8:49 AM

Answers

  • User475983607 posted

    Polachan, link (anchor) parameters are passed in the URL (HTTP GET).   Your code is incomplete so it is not possible to provide an accurate solution to solve your problem.  For example, you posted this in the JavaScript forum but are showing ASP.NET Core syntax.  Are you trying to get unobtrusive AJAX working?

    href="/Home/UpdateClockEntry?depotno=@Model.depotno&department=@Model.department&employeeid=@Model.employeeid" 

    You can also use standard tag helpers syntax, assuming this is a Core app,  which is covered in the openly published documentation.  Like many of your posts I recommend reading the docs, it really helps...

    <a asp-action="UpdateClockEntry" asp-route-depotno="1" asp-route-department="2" asp-route-employeeid="3">Link</a>

    You can learn HTTP GET and POST at the following ink.

    https://www.w3schools.com/tags/ref_httpmethods.asp

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 5, 2020 12:46 PM

All replies

  • User475983607 posted

    Polachan, link (anchor) parameters are passed in the URL (HTTP GET).   Your code is incomplete so it is not possible to provide an accurate solution to solve your problem.  For example, you posted this in the JavaScript forum but are showing ASP.NET Core syntax.  Are you trying to get unobtrusive AJAX working?

    href="/Home/UpdateClockEntry?depotno=@Model.depotno&department=@Model.department&employeeid=@Model.employeeid" 

    You can also use standard tag helpers syntax, assuming this is a Core app,  which is covered in the openly published documentation.  Like many of your posts I recommend reading the docs, it really helps...

    <a asp-action="UpdateClockEntry" asp-route-depotno="1" asp-route-department="2" asp-route-employeeid="3">Link</a>

    You can learn HTTP GET and POST at the following ink.

    https://www.w3schools.com/tags/ref_httpmethods.asp

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 5, 2020 12:46 PM
  • User-1355965324 posted

    Many Thanks mghbhred. I got  the solution for that. Many Many thanks for the help .

    Friday, March 6, 2020 4:10 PM
  • User-1330468790 posted

    Hi, polachan,

    We are glad that you have solved your problem.

    It would be great to mark the answer which helps you so that others with the similar problems will be able to find the right answer faster.

    Best regards,

    Sean

    Saturday, March 7, 2020 9:35 AM