Div as Ajax.ActionLink

Is it possible to create an Ajax.ActionLink that, instead of text, is the entire DIV?

I would like to impose a div on Ajax.ActionLink

+3
source share
1 answer

I don't think this will work using standard MVC Ajax scripts. I believe javascript MVC is designed to use the <a>default element . On the other hand, inserting a tag divinside is <a>not valid XHTML. What are you trying to achieve?

Using jQuery is probably the easiest way you want to go. As an example:

<div onclick="SomeAjaxFunction()">some div content</div>

function SomeAjaxFunction()
{
  $.get('<%= Url.Action("SomeAction", "InSomeController") %>', function(data) {
      $('.result').html(data); // assuming a partial view
      alert('Load was performed.');
});
}

, MS Ajax, div, , , Sys.Mvc.MvcHelpers._asyncRequest , . , . (Stick JQuery, .)

+2

Source: https://habr.com/ru/post/1755943/


All Articles