williamsandonz
williamsandonz

Reputation: 16460

ASP.NET Razor how to update ViewBag variable

Hey guys on my Base layout I have

<html lang="en" jsPageObject="@ViewBag.JSPageObject">

Then on the view, I have:

@{
    ViewBag.Title = "Details";
    ViewBag.JSPageObject = "MyDetails";
}

I've noticed the ViewBag.Title gets updated but not the JSPageObject..

Upvotes: 1

Views: 932

Answers (1)

Carles Company
Carles Company

Reputation: 7216

Most probably the <html> tag has already been rendered when you update the variable. Try setting it in your controller instead.

Upvotes: 3

Related Questions