ASP.NET MVC : AJAX ActionLink- Target an HTML attribute

后端 未结 3 528
名媛妹妹
名媛妹妹 2021-01-13 01:35

I have an Ajax actionlink that requests a string in the controller method. I want to insert that string into an attribute of a hyperlink. HOw do I specify the attribute fiel

3条回答
  •  深忆病人
    2021-01-13 02:00

    I'm not sure exactly what you mean but you can provide a set of HTML attributes some versions of the ActionLink extension.

    Ajax.ActionLink( string linkText,
                     string action,
                     object routeValues,
                     AjaxOptions ajaxOptions,
                     object htmlAttributes )
    

    Example:

    <%= Ajax.ActionLink( "add",
                         "AddThing",
                         new { id = ViewData.Model.ID },
                         new AjaxOptions { Confirm = "Are you sure?",
                                           UpdateTargetId = "thingList"
                                         },
                         new { title = "Add a thing to the database." } ); %>
    

提交回复
热议问题