Html.ActionLink: div as target

I am using this menu: http://www.stunicholls.com/menu/jquery-menutree.html

I am a piece of this menu:

<li><a href="#url">MyItem</a></li>

      

I replace with this:

<li><%= Html.ActionLink("MyItem", "Index", "ControllerName")%></li>

      

I would like to show the result in "MyDiv"

<div id="MyDiv">

</div>

      

How can i do this?

+2


source to share


2 answers


This is part of the ActionLink and is called a "fragment".

<%=Html.ActionLink("MyItem", "Index", "ControllerName", "http", "mysitename.com","MyDiv", null, null) %>

      

Or, if you want to use Url.Action:



<a href="<%=Url.Action("Index", "ControllerName") %>#MyDiv">MyItem</a>

      

I think Url.Action is the best, otherwise you need to specify things like protocol and hostname that you don't want to do everywhere.

You can always write an HTML helper that provides snippet functionality without having to specify the protocol and hostname, however ...

+4


source


You need to use Ajax.ActionLink like this:



Ajax.ActionLink (..., new AjaxOptions {UpdateTargetId = "mydiv"})

0


source







All Articles