views:

77

answers:

3

Hi I've built an asp website and i have the following issues:-

i'm using a master page in it and have defined two contentplaceholders one in head one in content, and i've specified the page title in the top most directive at the @page directive but the page title doesn't show up. I have to manually add a tag for it.

Secondly when i create a content page from a master page it creates it and when i rename it, it doesn't rename it's class. It remains _Default, thus every page was having an inherit to _default.

Most importantly I'm using a page to enter and view data to the database. I've used a boolean called isadmin which i set according to credentials at page load. and i'm added a panel where it's visible property is set to Visible = '<%#IsAdmin %>'. It works properly when i run it through the visual studio environment but when i publish it and run it doesn't work and the panel just comes and stays there. Why is it happening? Any idea? Thanks

The Visible problem is fixed as i had to enable windows authentication on the server. Awaiting answers for the other two issues. Thanks

+2  A: 
  1. Try to add a <head runat=server> to the master page. Only then ASP.net can "see" the tag and modify it
  2. It is not that bad that several aspx-pages have identical class names. ASP.NET 2.0 started to process every page as its own compiling unit or so. Pages cannot see each other. There is a special directive to make pages see each other and instanciate or manipulate them. So it should not do much harm
  3. Maybe you did not test this correctly and are mistaken that it DOES work in Visual Studio??? But in any case I would suggest that you move your logic into OnInit, then it runs much earlier. I think the control tree is build before Page.OnLoad. What you do is data binding, that might run only if DataBind is called, I'm not sure

Or use the safe way: Make IsAdmin a property so that it initializes itself on first call and caches the result in a variable

Christian
what do you mean by adding a to the master page?I got the admin thing to work, the webserver didn't have windows authentication enabled. But help me with the page titles.
Anirudh Goel
@Anirudh: I fixed the code formatting. Now you will understand what @Christian meant by "adding a to the master page". ;-)
Cerebrus
@Christian: IIRC, that should be <head runat="server">. Not the title tag.
Cerebrus
The other way is to drop a content placeholder into the <title> tags of the master page, and set the value in the content control.
Zhaph - Ben Duguid
A: 

Regarding question #2 - add your content pages via Project -> Add New Item, and name it appropriately there. That way the naming is consistent and correct throughout.

Regarding #3, what HTML is output when you run it from the server?

Scott Ewers
A: 

your first issue can be solved by filling out the title part of the @Page directive in your .aspx pages. The master page will display that text in the browsers title bar.

and prob #2 should be solved by adding the files using the file add option in visual studio.

jonezy
i've already tried filling the title at the @Page directive, it didn't work for me!
Anirudh Goel