Show/Hide panels in ASP.net C# after submitting form


So in the process of combining my default.aspx form page with the confirm.aspx confirmation page, I had to create panels and show/hide them at the initial loading of the page.

The form is a comment/complaint form, so users will submit their info, and an e-mail is generated and sent to a web master.

I have 4 panels: Panels 1 + 3 show by default and are set to visible early in the script like so:

protected void Page_Load(object sender, EventArgs e) { Panel1.Visible = true; Panel2.Visible = false; Panel3.Visible = true; Panel4.Visible = false; }

Basically, I want panels 1+3 to become hidden, and 2 + 4 to become visible once the user submits the form and no errors are found within the forum.

Would I run the script to change the visibility at the try function when an email is sent, or right before the frmReset function?

Also, is there a specific function I need that will switch the panels visibility AFTER submitting the form with no errors found? (Other than changing visibility to true or false)


According your comments, you will resolve your requirement in two steps.

1st, update your page load to avoid reverting visibility after you change it :

protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack){ Panel1.Visible = true; Panel2.Visible = false; Panel3.Visible = true; Panel4.Visible = false; } }

2nd, you have to change the visibility on the try method :

protected void Try_Click(object sender, EventArgs e) { Panel1.Visible = false; Panel2.Visible = true; Panel3.Visible = false; Panel4.Visible = true; }


  • Collapse plugin: Only show one panel at a time
  • Moving JPanels using TimerTask
  • Scala: How to check if all items are unique in a Seq?
  • PHP IntlDateFormatter wrong date/time conversion
  • How can I dynamically add controls to a form based on JComboBox selection?
  • How to replace spaces at the right into zeros at the left in COBOL?
  • What are some techniques to monitor multiple instances of a piece of software?
  • Accessing another variable in the same class with a click event
  • auth.provider is not set to 'password' when user signs-in with email and password
  • Getting unread count in Sent Folder using Google Apps Script - GMail
  • Why can't UI components be accessed from a backgroundworker?
  • react split panel resize
  • Mixing WebForms and MVC: What should I do with the MasterPage?
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • JSON encode and decode on PHP
  • Building Qt project for C++11 standard
  • Click on button in another program - FindWindow, C#
  • How to get links to open in the native browser in iOS Meteor apps?
  • How to getText() from the input field of an angularjs Application
  • c# open webrowser in many tab
  • CakePHP 2.0.4 - findBy magic methods with conditions
  • How to Cache Real-time Data?
  • Email verification using google app script and google forms
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Ajax Loaded meta Tags
  • How to rebase a series of branches?
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • How to set/get protobuf's extension field in Go?
  • Cassandra Data Model
  • Trying to switch camera back to front but getting exception
  • Importing jscolor library in angular 2
  • AT Commands to Send SMS not working in Windows 8.1
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • sending mail using smtp is too slow
  • reshape alternating columns in less time and using less memory
  • UserPrincipal.Current returns apppool on IIS