views:

265

answers:

2

Hello,

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

I piece of this menu is :

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

I replace by this :

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

I'd like show the result in "MyDiv"

<div id="MyDiv">

</div>

How can I do this ?

thanks,

+3  A: 

It is part of ActionLink, and is called '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 that the Url.Action is the best one, otherwise you have to specify things like the protocol and hostname, which you don't want to be doing everywhere.

You could always write a HTML Helper which provides the fragment functionality without the requirement of specifying the protocol and hostname however...

Dan Atkinson
A: 

You need to use Ajax.ActionLink like this:

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

queen3