OK, i am mostly a php person, with a smattering of classic asp. but the current project I am on is a .net project based on masterpages.
ok, masterpages, cool. kind of like a super template system. abstract away all the structure from the content. awesome.
small snag. i need to communicate a variable back to the masterpage from the content page.
I can pull the file name from the page
string[] pagename = System.IO.Path.GetFileName(Page.Request.PhysicalPath).ToLower().Split('.');
but i'd really like to get the content id
<asp:Content ID="subpage" ContentPlaceHolderID="mainContent" Runat="Server">
the basic idea is that i am setting the body class on a per page basis so that I can set css sprites, over, and here states.
anybody have any ideas? is this possible?
Posts
Does that help?
basically, what i am trying to replicate is in php:
<? $pagename = "about";
include("header.php");
?>
content blah blah blah
where in the header.php file is all the templated html gubbins, with outputs of the $pagename variable in various places
<body class="<?echo($pagename);?>">
so that I can have a css file that automagically tracks 'here' states
.about a.btn {background:#fff;}
with
string[] pagename = System.IO.Path.GetFileName(Page.Request.PhysicalPath).ToLower().Split('.');
masterBody.Attributes.Add("class", pagename[0]);
in the master.cs i can get the file names printed as a class name. but then we need to worry about people using the right page name. with the php code above, any random person could make a page, attach the header, and it would automatically have the right css classes.
worst problem i'm having is basically trying to track down the object model and how the pages communicate to each other...
doesn't help i've been doing .net for 3 days total now.
Soulstalkers idea might work and may be the best bet for code-file borne variables.
If you need to find an actual page control, you can use a method on the asp:content control something along the lines of "findControl()" and then cast it to whatever is appropriate
This is one of the uglier parts of .NET
It would be easier if I could see your page code.
we also talk about other random shit and clown upon each other
In the master:
In the child:
masterpage, stripped of everything but the contentplaceholder
and Legionaired, its less costom styles for any given page, and more using the cascade to automagically set 'here' states on buttons, set the backgroundimages for titles and things like that. and having that many extra css files makes maintenance a bit more nightmarish. one masterpage and one css file to rule them all.
soulstalker:
Page.GetType() returns the same thing as Page.Request.PhysicalPath. which still requires me to know what the page will be name, rather than declaring what the page is.
i'd love to be able to (psuedocode!) Page.ContentPlaceHolderId["mainContent"].ID, but that evidently does not work.
thanks for all the help so far, giving me terms to search from at least.