Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6538909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:47:34+00:00 2026-05-25T10:47:34+00:00

I have got myself really tied up with a web user control and the

  • 0

I have got myself really tied up with a web user control and the changing of a <div>‘s visibility in the parent ASPX.

I have a shopping cart which is inside a User Control and within one of the pages the UC is included there is a status <div> which shows a summary of the cart contents. If the cart is empty it shows a different <div>.

Code in UC

if (varCartStatus)
{
  cartStatusTrue.Visible = true;
  cartStatusFalse.Visible = false;
else
{
  cartStatusTrue.Visible = false;
  cartStatusFalse.Visible = true;
}

All I get at the moment is
‘cartStatusTrue’ does not exist in the current context.
‘cartStatusFalse’ does not exist in the current context.

How do I get the UC to change the visibility of the <div> that’s in the parent ASPX?

Sorry, I very new to .net and C# and I’m totally lost (again!)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:47:34+00:00Added an answer on May 25, 2026 at 10:47 am

    Since the controls exist in the page, and not the control, you have to find them in the page:

    this.Page.FindControl("cartStatusTrue").Visible = varCartStatus;
    this.Page.FindControl("cartStatusFalse").Visible = !varCartStatus;
    

    Or similarly, if they were in a parent control:

    this.Parent.FindControl("cartStatusTrue").Visible = varCartStatus;
    this.Parent.FindControl("cartStatusFalse").Visible = !varCartStatus;
    

    Of course, also make sure your divs both have runat="server" and ID="cartStatusTrue" or ID="cartStatusFalse".

    Edit: Another option that is probably a design improvement would be to move the job of hiding the div to the aspx page. You could expose varCartStatus as a property of the control and read that property from the aspx page. In your aspx.cs:

    this.cartStatusTrue.Visible = this.CartControl.CartStatus;
    this.cartStatusFalse.Visible = !this.CartControl.CartStatus;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code and got myself confused: I have a query that
I have got myself a server, and on it I'd like to host my
I recently got myself a second monitor and I have been looking at software
I wonder whether someone could help me please. I've really got myself in a
Have got an NSString *str = @12345.6789 and want to find out if there
We have got a custom MembershipProvider in ASP.NET . Now there are 2 possible
We have got loads of options for php + MySQL + Apache combo... Which
I have got a python script which is creating an ODBC connection. The ODBC
I have got a C function in a static library, let's call it A,
I have got the following problem since the server has safe mode turned on,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.