how to create an else if statement in Razor?

后端 未结 3 1242
终归单人心
终归单人心 2020-12-09 16:11

I am trying to display some rows in a table. Depending on the UserGroup, the View should show different markup. An administrator can delete rows, but a moderator can only ma

3条回答
  •  伪装坚强ぢ
    2020-12-09 16:37

    as the question is for else if in razor, i used this for SEO purpose

    in view

    @{
        if (ViewBag.Option == "Mobiles")
    {
        ViewBag.Title = "Mobiles";
        ViewBag.Description = "Mobiles";
        ViewBag.Keywords = "Mobiles";
    
    }
    
       else if (ViewBag.Option == "holiday")
    {
        ViewBag.Title = "holiday";
        ViewBag.Description = "holiday.";
        ViewBag.Keywords = "holiday";
    }
    
    
    else
        {
            ViewBag.Title = "home";
            ViewBag.Description = "home";
            ViewBag.Keywords = "home";
        }
    
    }
    

    hope helps someone.

提交回复
热议问题