Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Posted

What do you mean ?

It's not invisible in Design mode or within the browser ?

"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

Posted
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.
Posted

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??????

Thanks,

 

Bill Yeager (MCP, BCIP)

Microsoft Certified Professional

Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer

YeagerTech Consulting, Inc.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...