0

I am using MVC and my requirement is that i need to build a action link with dynamic action route value.

for example.

In my model i have the list<string> so action link should be.

../ActionMethodName/ControllerName? Item[0]=model.item[0]&Item[1]=model.Item[1]...so on.

Any Suggestion is welcome.

Kuldeep
  • 454
  • 1
  • 3
  • 11
  • So....what have you tried? – Mathew Thompson May 13 '15 at 12:03
  • I am trying to create extension method..to generate custom action link. but now facing another issue and same issue is in this post...http://stackoverflow.com/questions/11057583/webgrid-cannot-convert-from-lambda-expression-to-system-funcdynamic-object – Kuldeep May 13 '15 at 14:31
  • Note this action link need to use in web grid. – Kuldeep May 13 '15 at 14:32

2 Answers2

0

Several ways.

1) You can pass as array and access it.

3) You can use foreach with razor syntex to generate this type of link.

Niket
  • 41
  • 2
  • 5
  • I can't pass as array, i need to send in mentioned format (Item[0]=model.item[0]&Item[1]=model.Item[1]...so on)....2nd point for each...i am not sure how to use while declaring routevalue in action method..Please post some sample code.. – Kuldeep May 13 '15 at 12:15
0

Initally , the parameter needs to be passed are hardcoded than OnClick of somthing , replace the queryString values .

@Ajax.ActionLink("Test", "actionName", "ControllerName", new { foo = "foo1", name = "ABC" }, new AjaxOptions { UpdateTargetId = "TargetName" }, new { id = "Test" })

and

 $("#btnTest").click(function () {
      // Replace the hardcoded parameter value desired one ... :)  
      $("#Test").attr('href', $("#Test").attr('href').replace("foo1", "XXX"))     
    });

Note:- this solution i read from asp.net forums

http://forums.asp.net/t/1841591.aspx?+pass+Javascript+value+parameter+with+Ajax+ActionLink

developer
  • 1,565
  • 1
  • 9
  • 12