Click here to Skip to main content
15,071,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i want to pass the values , view to controller ...

my code
HTML
<input name="Players[0].Level" id="Players_0__Level" type="radio" checked="checked" value="@t"><label for="Players_0__Level">@t</label>

script
HTML
<script>
    $(document).ready(function () {
        $("#Players_0__Level").on("click", function () {
            location.href = '/SportsDept/Create/' + $(this).find('#Players_0__Level').val();
        });
    });
</script>

i am using "find('#Players_0__Level').val();" but this cod nnot working...
please give a solution for my problem..

Regards
-AR
Posted
Updated 12-Mar-14 23:53pm
v3

1 solution

Use $(this).val() or $('#Players_0__Level').val();
   
Comments
An@nd Rajan10 13-Mar-14 6:46am
   
this not work
R-a-v-i-k-u-m-a-r 13-Mar-14 6:55am
   
Is it throws any error? if not what value will be passed to the action result in controller?
An@nd Rajan10 13-Mar-14 7:14am
   
thank you..
how to get the value in controller give an one line example
An@nd Rajan10 13-Mar-14 7:17am
   
thank you.. how to get the value in controller give an one line example
R-a-v-i-k-u-m-a-r 13-Mar-14 7:25am
   
Public ActionResult Methode(datatype id)
{
}
put a break point and check the value
An@nd Rajan10 13-Mar-14 7:36am
   
i am using like
public ActionResult Create(string sports)
{
ViewBag.SportsNams = sports;
return View();
}

sports is null..
what is the mistake..
R-a-v-i-k-u-m-a-r 13-Mar-14 7:41am
   
For that you have to define a custom route that accepts sports parameter
or you change the link href in the form of query string
/SportsDept/Create?sports=' + $(this).val()

by default routing action methods accepts the id as a parameter
An@nd Rajan10 13-Mar-14 7:44am
   
thank you soooo much its works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900