Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set page title with ViewBag in ASPX mode?

I have a master page called Default.master. I want to set the title using ViewBag.Title. On my controller I have:

public ActionResult Index()
{
    ViewBag.Title = "Home";
    return View();
}

My Home view uses Default.master as the master view page. On the master view page I am using:

<title><%= ViewBag.Title %></title>

But I get this error:

The call is ambiguous between the following methods or properties: 'System.IO.TextWriter.Write(string, params object[])' and 'System.IO.TextWriter.Write(char[])'

How can I use it properly?

like image 975
BrunoLM Avatar asked Jan 24 '11 21:01

BrunoLM


1 Answers

Try:

<title><%= (string) ViewBag.Title %></title>
like image 96
santiagoIT Avatar answered Sep 28 '22 06:09

santiagoIT