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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.Write (usertag) probelm 1

Status
Not open for further replies.

gi11ies

Programmer
Mar 26, 2002
52
This may seem pretty simple, but I just cant get my head around it! I have two different navigation bars, where the code for each is in seperate user controls.

I want a different navigation bar displayed depending on the state of a variable - is this case it is if the login state variable I have declared is true.

After the user controls are declared and called.

The code I use is as follows:

Sub Page_Load(S As Object, E As EventArgs)
Dim logState as Boolean = True (set to true for testing)
If logState = True
Response.Write("<Nav:SignIn runat='server'/>")
Else
Response.Write("<Nav:SignOut runat='server'/>")
End If
End Sub

If anyone can tell me what I am doing wrong of suggest another method? it would be great!
 
Hi,

First thing is I do not beleive you can do it that way. That is put a tag in that is asking it to be running at server. Becuase inorder to analyze that code it is already running at the server level. IT would need to run the code twice..which as far as I know it can't do.

My solution would be this:

1) use an ASP Panel around each Nav bar state
Setting each one with a unique ID for the panel
Example:
NavSignin
NavSignOut
2) On page_load I would:
if (logstate=true) then
NavSignin.visible = false
NavSignOut.visible = true
else
NavSignin.visible = true
NavSignOut.visible = false
end if

This will allow you to display one menu or the other when producing the HTML page.

I hope that made sense.

Angela
 
Thanks Angela - made perfect sense, and worked a treat !!!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top