Jun 8, 2004 #1 lunargirrl Programmer Joined Jan 26, 2004 Messages 77 Location BR How can I clear the controls of a page (labels, textboxes, etc..) when the back and forward buttons of the browser are pressed?? Thanks a lot, Gis.
How can I clear the controls of a page (labels, textboxes, etc..) when the back and forward buttons of the browser are pressed?? Thanks a lot, Gis.
Jun 8, 2004 #2 AtomicChip Programmer Joined May 15, 2001 Messages 622 Location CA This should work, assuming that you're trying to clear the control's contents (you might have to change it up a bit - it's hand-coded): Code: foreach(System.Web.UI.Control c in this.Page.Controls) { if(c.GetType() == typeof(Label)) ((Label)c).Text = String.Empty; if(c.GetType() == typeof(TextBox)) ((TextBox)c).Text = String.Empty; if(c.GetType() == typeof(DropDownList)) ((DropDownList)c).Items.Clear(); } You'll also have to add in handlers for any other control types that you want to clear on your page. Hope that helps ----------------------------------------------- http://www.liquidfuzion.com"The night sky over the planet Krikkit is the least interesting sight in the entire universe." -Hitch Hiker's Guide To The Galaxy Upvote 0 Downvote
This should work, assuming that you're trying to clear the control's contents (you might have to change it up a bit - it's hand-coded): Code: foreach(System.Web.UI.Control c in this.Page.Controls) { if(c.GetType() == typeof(Label)) ((Label)c).Text = String.Empty; if(c.GetType() == typeof(TextBox)) ((TextBox)c).Text = String.Empty; if(c.GetType() == typeof(DropDownList)) ((DropDownList)c).Items.Clear(); } You'll also have to add in handlers for any other control types that you want to clear on your page. Hope that helps ----------------------------------------------- http://www.liquidfuzion.com"The night sky over the planet Krikkit is the least interesting sight in the entire universe." -Hitch Hiker's Guide To The Galaxy
Jun 8, 2004 Thread starter #3 lunargirrl Programmer Joined Jan 26, 2004 Messages 77 Location BR AtomicChip, do i place that in the page load?? thanks gis. Upvote 0 Downvote
Jun 8, 2004 #4 AtomicChip Programmer Joined May 15, 2001 Messages 622 Location CA You'd probably want to place that on your back and forward button click events. ----------------------------------------------- http://www.liquidfuzion.com"The night sky over the planet Krikkit is the least interesting sight in the entire universe." -Hitch Hiker's Guide To The Galaxy Upvote 0 Downvote
You'd probably want to place that on your back and forward button click events. ----------------------------------------------- http://www.liquidfuzion.com"The night sky over the planet Krikkit is the least interesting sight in the entire universe." -Hitch Hiker's Guide To The Galaxy
Jun 8, 2004 Thread starter #5 lunargirrl Programmer Joined Jan 26, 2004 Messages 77 Location BR how can i manipulate the back and forward buttons of my browser by code? in vs.net? Thanks ) Gis. Upvote 0 Downvote