I use Facebook api and load albums from Facebook, display image gallery using usercontrol and want to assign page title according to album name. I load the usercontrol using Umbraco macros.
If I assign Page.Title in usercontrol's PageLoad and then try to access it in razor script (which is on the same page, but obviously has nothing to do with the usercontrol above) it is null.
Basically my question is how can I pass any string from usercontrol to Umbraco context and how to access it (from template or macros script)? It's NOT necessary to use Page.Title, any way will do.
How to set a page title from usercontrol and access it in razor script?
I need to set a page title programmatically on some pages, but still be able to display the value from Umbraco if it's not set. How can I do it?
In my usercontrol PageLoad I do:
Page.Title = "My title";
I want to access it in my razor script, something like this:
string title = Page.Title;
if (string.IsNullOrEmpty(title)) {
title = Model.Title;
}
It doesn't work though, how can I do it?
Normaly it's the ViewBag.Title.. can't you set that?
I need to do it from codebehind of .ascx usercontrol, I can't use ViewBag, can I?
You say from codebehind? Why, can't you do in razor?
string title = Page.Title;
if (string.IsNullOrEmpty(title)) {
ViewBag.Title = Model.Title;
}
I use Facebook api and load albums from Facebook, display image gallery using usercontrol and want to assign page title according to album name. I load the usercontrol using Umbraco macros.
If I assign Page.Title in usercontrol's PageLoad and then try to access it in razor script (which is on the same page, but obviously has nothing to do with the usercontrol above) it is null.
So in codebehind I have :
protected void Page_Load(object sender, EventArgs e) {
...
Page.Title = "my title";
...
}
in razor script
string title = Page.Title // it's null
Basically my question is how can I pass any string from usercontrol to Umbraco context and how to access it (from template or macros script)? It's NOT necessary to use Page.Title, any way will do.
Sorry that i don't have that answer...
is working on a reply...