Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Control properties changing during page processing

Control properties changing during page processing

Scheduled Pinned Locked Moved ASP.NET
htmldebuggingquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    badgrs
    wrote on last edited by
    #1

    Hi, I have a page with a Panel control with its Visible property set to false in the markup. I've then got a button event handler that sets this to true. When the page renders this has somehow found its way back to false. Using some logging and debugging I've determined that the event is definately working as expected, but by the time the OnPreRender event fires the property has changed back. Can anyone explain this?

    protected override void OnPreRender(EventArgs e)
        {
            log.Debug("PreRender, visible: " + AccessInfoContentPanel.Visible);
            base.OnPreRender(e);
        }
    
        private void ToggleContent()
        {
            if (AccessInfoContentPanel.Visible == false)
            {
                log.Debug("content made visible: ");
                AccessInfoContentPanel.Visible = true;
                AccessInfoContentPanel.Enabled = true;
            }
            else
            {
                log.Debug("content removed: ");
                AccessInfoContentPanel.Visible = false;
                AccessInfoContentPanel.Enabled = false;
            }
        }
    
        protected void ToggleBtn_ServerClick(object sender, EventArgs e)
        {
            ToggleContent();
        }
    

    Cheers!

    A K 2 Replies Last reply
    0
    • B badgrs

      Hi, I have a page with a Panel control with its Visible property set to false in the markup. I've then got a button event handler that sets this to true. When the page renders this has somehow found its way back to false. Using some logging and debugging I've determined that the event is definately working as expected, but by the time the OnPreRender event fires the property has changed back. Can anyone explain this?

      protected override void OnPreRender(EventArgs e)
          {
              log.Debug("PreRender, visible: " + AccessInfoContentPanel.Visible);
              base.OnPreRender(e);
          }
      
          private void ToggleContent()
          {
              if (AccessInfoContentPanel.Visible == false)
              {
                  log.Debug("content made visible: ");
                  AccessInfoContentPanel.Visible = true;
                  AccessInfoContentPanel.Enabled = true;
              }
              else
              {
                  log.Debug("content removed: ");
                  AccessInfoContentPanel.Visible = false;
                  AccessInfoContentPanel.Enabled = false;
              }
          }
      
          protected void ToggleBtn_ServerClick(object sender, EventArgs e)
          {
              ToggleContent();
          }
      

      Cheers!

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      My guess is that the initial setting the panel to visible = false might be happening in the page load as well? Or perhaps you have viewstate turned off? That is where I have usually found these bugs. I have done some very similar things in ASP.net. NOTE a better way to do what you are trying to do might be to use a PlaceHolder control instead. Anyway, hope that helps. Ben

      1 Reply Last reply
      0
      • B badgrs

        Hi, I have a page with a Panel control with its Visible property set to false in the markup. I've then got a button event handler that sets this to true. When the page renders this has somehow found its way back to false. Using some logging and debugging I've determined that the event is definately working as expected, but by the time the OnPreRender event fires the property has changed back. Can anyone explain this?

        protected override void OnPreRender(EventArgs e)
            {
                log.Debug("PreRender, visible: " + AccessInfoContentPanel.Visible);
                base.OnPreRender(e);
            }
        
            private void ToggleContent()
            {
                if (AccessInfoContentPanel.Visible == false)
                {
                    log.Debug("content made visible: ");
                    AccessInfoContentPanel.Visible = true;
                    AccessInfoContentPanel.Enabled = true;
                }
                else
                {
                    log.Debug("content removed: ");
                    AccessInfoContentPanel.Visible = false;
                    AccessInfoContentPanel.Enabled = false;
                }
            }
        
            protected void ToggleBtn_ServerClick(object sender, EventArgs e)
            {
                ToggleContent();
            }
        

        Cheers!

        A Offline
        A Offline
        Abisodun
        wrote on last edited by
        #3

        I've experienced an issue in the past where changes in the browser do not make it to the server code when a control is disabled. Test the same code with AccessInfoContentPanel always enabled. You may want to enable before changing visible to true.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups