Raihan Ridoy

Raihan Ridoy

  • NA
  • 24
  • 1.2k

How to retrieve an actionlink text in a controller?

May 19 2018 2:19 AM

I have a list of actionlink in my navbar like this

  • @Html.ActionLink("Customer Profile", "Index", "Profile")
  • @Html.ActionLink("Supplier Profile", "Index", "Profile")
  • @Html.ActionLink("Publisher Profile", "Index", "Profile")
  • now i need to retrieve the link text in my controller to allocate some value in a property by comparing the value of the link text like this

     [HttpGet] public ActionResult Index() 
    {
        Profile profile = new Profile();
        if(linktext=="Customer Profile") 
         {            
              profile.cust_supply_cat_id = 1; 
         } 
          else if (linktext == "Supplier Profile") 
             {
                 profile.cust_supply_cat_id = 2;
             } 
          else if (linktext == "Publisher Profile")
              {        
                  profile.cust_supply_cat_id = 3;
              } 
           return View(profile); 
    }

    How can i do it?

    or if you get the idea what are the possible ways to do that??


    Answers (1)