Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

master page question

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
Dozens of my webforms use the same masterpage. My master page has a label. This label ought to be invisible on ONE of the webforms.

If I write anything about this label in my webform, VS freaks out because the label is not on the webform. So I need to write my code in the master page.

I am considering a couple of different solutions to this problem:

1. In my master page, could I write something like "If you are applied to webform1, hide labela"? Can you get me started on the syntax for that?

2. I have a treeview on my masterpage. Identifying the selected node would tell me which web form is instantiated. I tried Response.Write(TreeView1.SelectedNode.Text). Unfortunately I get an error stating that TreeView1 has not been instantiated. This happens whether I use the page_load event or the Page_PreRender event. How could I overcome this chicken-egg problem??

I look forward to your feedback on solutions one and two.
 
I just recognized that Me.Request.Url.ToString() may solve my problem. I am investigating this now.
 
Yes! Putting this code in the master page's load event fixed the issue:
Code:
Dim myPage As String = Me.Request.Url.ToString
Dim startPoint As Int32 = myPage.LastIndexOf("/") + 1
myPage = myPage.Substring(startPoint)
If myPage = "logout.aspx" Then
       Label1.Visible = False
End If
 
That code smells a little bit. --phrase i got from one of the older devs.

This is just a suggestion

What if you have a boolean on the page along the lines of HideSomeThings and if true then hide the control(s).

If you have to do something once, more like than not, you will have to do it a second time, later.

-Sometimes the answer to your question is the hack that works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top