wsyeager Posted April 26, 2004 Posted April 26, 2004 I have a usercontrol which I would like to make invisible based on a certain condition as follows: Protected SchedulingAdminLogout As New YTCIWebUserControls.SchedulingAdminLogout . . . If DirectCast(ViewState.Item("PCREntry"), String) = "1" Then SchedulingAdminLogout.Visible = False End If While debugging, it does go inside the IF statement (which I'm expecting), but the user control remains visible on the webform. How can I set the visibility to false based on this condition? Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Arch4ngel Posted April 26, 2004 Posted April 26, 2004 What do you mean ? It's not invisible in Design mode or within the browser ? Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
akiaz Posted April 26, 2004 Posted April 26, 2004 Are you doing this in Page_Load? If you are setting the property too late, then the HTML is already rendered and the user control will be visible. Quote
Moderators Robby Posted April 26, 2004 Moderators Posted April 26, 2004 place the UC in a Panel, then you can control the state of the panel. Quote Visit...Bassic Software
wsyeager Posted April 27, 2004 Author Posted April 27, 2004 Robby, I have the following code in my page load event of the webform: <code> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then ViewState.Item("InitialTime") = DirectCast(Request.QueryString.Item("InitialTime"), String) ViewState.Item("PCREntry") = DirectCast(Request.QueryString.Item("PCREntry"), String) BindData() End If If DirectCast(ViewState.Item("PCREntry"), String) = "1" Then Dim tblAdminSchedulingLogout As Table = SchedulingAdminLogout.FindControl("tblAdminSchedulingLogout") tblAdminSchedulingLogout.Visible = False End If End Sub </code> Unfortunately, the tblAdminSchedulingLogout variable is still set to Nothing after executing the FindControl statement. I have the following code in my usercontrol: <code> <table id="tblAdminSchedulingLogout" align="right" style="Z-INDEX: 103; LEFT: 750px; POSITION: absolute; TOP: 12px" runat="server"> <tr> <td><asp:Button id="btnMainMenu" runat="server" Text="Main Menu" CausesValidation="False"></asp:Button></td> <td></td> <td></td> <td><asp:Button id="btnLogout" Text="Logout" runat="server" CausesValidation="False"></asp:Button></td> </tr> </table> </code> As you can see, I'm giving the table an ID. However, I still can't access the table from within my webform (as evidenced by the FindControl method). I'm trying to set the table to invisible once I find the control. I don't know why I can't find the control?????? Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.