November Happy Hour will be moved to Thursday December 5th.

Can't use Container.CurrentPage in CodeBehind - how to do instead?

Vote:
 
I've created a page property of Boolean type, and I try to check the state before rendering some text on a page. As long as the value is "true" there's no problem, but since the value "false" is not stored in the database I need to handle the Null-value in some way. Here's what I do, and it works fine on a page - it's just that I want to do this in a PageList, and instead of calling CurrentPage["NotScheduled"] I want to call Container.Currentage["NotScheduled"] in an ItemTemplate. I just can't make it work. The HTML part: <%if (scheduledstate(currentpage)="=" "false") { %> <% } %> The CodeBehind: protected string ScheduledState(PageData page) { if (page["NotScheduled"] != null) { _ScheduledState = page["NotScheduled"].ToString(); return "true"; } else { return "false"; } }
#12240
Mar 16, 2005 8:20
Vote:
 
That is, the following doesn't work, it tells me "The type or namespace name 'Container' could not be found (are you missing a using directive or an assembly reference?)" <%if (ScheduledState(Container.CurrentPage) == "false") { %>
#13903
Mar 16, 2005 8:24
Vote:
 
Why not do it like this and save yourself mixing code with html so much! <%#ScheduledState(Container.CurrentPage)%> (html page calls a function, passing the Container.CurrentPage to the code behind) then in code behind: protected string ScheduledState(PageData page) { //your logic should be done here and the value you want to display sent back to the browser... if (page["NotScheduled"] != null) { return page["whatever"].ToString(); } else { return string.empty; } }
#13904
Mar 16, 2005 9:20
Vote:
 
That's actually a good way to go after all - although I would have preferred to be able to use EPiServer properties in the aspx page instead och putting strings together in the Code Behind. But anyway - it helped me! Thanx!
#13905
Mar 16, 2005 10:35
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.