asp.net - Recognize particular id in ajax form mvc3 from several hyperlink -


I am currently working on an MVC3 project, I am currently stuck on this part.

I have this Ajax form which contains many hyperlinks

  @using (Ajax.BeginForm ("click", new AjaxOptions {UpdateTargetId = "Showpage"}) ) {& Lt; A href = "#" id = "0" onclick = 'document.forms [0]. Submit () '& gt; Link 0 & lt; / A & gt; & Lt; A href = "#" id = "1" onclick = 'document.forms [0]. Submit () '& gt; Link 1 & lt; / A & gt; }   

I have a function called "click" in this controller whenever the link is clicked.

  Click Public Function (String ID) {// action here}   

However, whenever I click on one of the hyperlinks, click The function is obtained as a "null". When I enter the controller, I want to know the function to click on the hyperlink. From my understanding, I seems

/ Strong> you are doing something after this:

HTML :

  & lt; Div id = "showpage" & gt; & Lt; / {@id = "myAjaxForm"}) using {@ Html.ActionLink ("" "" "") (avx benfinform ("click", "new, ajax option {updateTargetId =" showpage "} , @ Link "," click ", blank, new {@id =" Link0 ", @data_val =" 0 ", @class =" links "}) @HTMLconnect (" link 1 "," click " , Empty, new {@id = "Link1", @data_val = "1", @class = "links"}) @ Html.Hidden ("id", "");}   < P>  SCRIPT :  
  & lt; script & gt; $ (function () {$ ('a [class = links]'). (E) {e.preventDefault $ ("Input # ID"). Val ($ (this) .attr ("data-val")); $ ('form # myAjaxForm'). Submit ()  } {Return to content ("id =" + id, "text / html")}} {var m = new MyModel (); return view (m);} [http post] pub live action result click (string id) / Code>  

Hope this helps

Comments