Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
I am having a < href > attributes in my .cshtml page at mvc4 @cp.Name
in my mvc 4 .... what i need is if a person clicks the above link . i have to redirect him to any of the ActionName in Controller (for eg: Index in HomeController )...... how to do it. In my above sample i have redirected to google.com...... but i need to redirect to any of actionname in controller......


My code:


@{
List<menurazor.models.menuitem> menulist = ViewBag.Menu;
}




@helper RenderMenuItem(List<menurazor.models.menuitem> menuList, MenuRazor.Models.MenuItem mi)
{
foreach (var cp in menuList.Where(p => p.ParentMenu_Id == mi.Id))
{


@:


  • @cp.Name


    if (menuList.Count(p => p.ParentMenu_Id == cp.Id) > 0)
    {
    @:

      }

      @RenderMenuItem(menuList, cp)
      if (menuList.Count(p => p.ParentMenu_Id == cp.Id) > 0)
      {
      @:

    }
    else
    {
    @:
  • }
    }
    }
    Posted
    Updated 18-Sep-13 18:04pm
    v4
    Comments
    Jameel VM 18-Sep-13 12:00pm    
    where you specifying the url need to be redirected? could you post the code you have tried?

    1 solution

    C#
    @Html.ActionLink(
        "Reply",                                                  // linkText
        "ReplyCommentAdd",                                    // actionName
        "Comment",                                                   // routeValues
        new {                                                     // htmlAttributes
            PostId = PostId,
            
        }
    )
     
    Share this answer
     

    This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



    CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900