| | |
How to check if page has been modified?
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2009
Posts: 26
Reputation:
Solved Threads: 0
I have a wizard control. On one of its pages I have various controls like textboxes and checkboxes. Could anybody please tell me how I can check from my code (e.g. on Cancel) if the contents of the controls has been changed? I know how to check if each control was changed separately, but is there any way to check the page as a whole?
hope this helps...
For the aboove code, instead of making it empty, I would check to see if there is anything inside of them and loop through with a flag(boolean) and run a check at the end.
ASP.NET Syntax (Toggle Plain Text)
public static void ClearForm(System.Windows.Forms.Control parent) { foreach (System.Windows.Forms.Control ctrControl in parent.Controls) { //Loop through all controls if (object.ReferenceEquals(ctrControl.GetType(), typeof(System.Windows.Forms.TextBox))) { //Check to see if it's a textbox ((System.Windows.Forms.TextBox)ctrControl).Text = string.Empty; //If it is then set the text to String.Empty (empty textbox) } else if (object.ReferenceEquals(ctrControl.GetType(), typeof(System.Windows.Forms.RichTextBox))) { //If its a RichTextBox clear the text ((System.Windows.Forms.RichTextBox)ctrControl).Text = string.Empty; } else if (object.ReferenceEquals(ctrControl.GetType(), typeof(System.Windows.Forms.ComboBox))) { //Next check if it's a dropdown list ((System.Windows.Forms.ComboBox)ctrControl).SelectedIndex = -1; //If it is then set its SelectedIndex to 0 } else if (object.ReferenceEquals(ctrControl.GetType(), typeof(System.Windows.Forms.CheckBox))) { //Next uncheck all checkboxes ((System.Windows.Forms.CheckBox)ctrControl).Checked = false; } else if (object.ReferenceEquals(ctrControl.GetType(), typeof(System.Windows.Forms.RadioButton))) { //Unselect all RadioButtons ((System.Windows.Forms.RadioButton)ctrControl).Checked = false; } if (ctrControl.Controls.Count > 0) { //Call itself to get all other controls in other containers ClearForm(ctrControl); }
For the aboove code, instead of making it empty, I would check to see if there is anything inside of them and loop through with a flag(boolean) and run a check at the end.
•
•
Join Date: Jul 2009
Posts: 26
Reputation:
Solved Threads: 0
Thanks, it did help. I still have problem though. Here is how I use it:
I call this method from my custom code behind parent class' Page_Load:
But when I run the application and change the value in the textbox, I do not come to OnValueChanged(). Could you explain why it doesn't happen?
Thank you very much,
Dmitriy
ASP.NET Syntax (Toggle Plain Text)
protected void OnValueChanged(object sender, EventArgs e) { ViewState["IsModified"] = true; } protected void SubscribeForOnChange(Control parent) { foreach (Control ctrControl in parent.Controls) { //Loop through all controls if (object.ReferenceEquals(ctrControl.GetType(), typeof(TextBox))) { ((TextBox)ctrControl).AutoPostBack = true; ((TextBox)ctrControl).TextChanged += new EventHandler(OnValueChanged); } ... } }
ASP.NET Syntax (Toggle Plain Text)
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack && wizSummaryDetails.ActiveStep == wizStepSummary) { ViewState["IsModified"] = false; SubscribeForOnChange(this); ...
Thank you very much,
Dmitriy
Last edited by peter_budo; Jul 10th, 2009 at 6:19 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
sure... in the meta tag at the top of the html.... insert this between the <head></head> tags
where you replace x with how many seconds you want to wait before you refresh
ASP.NET Syntax (Toggle Plain Text)
<meta http-equiv="refresh" content="x">
where you replace x with how many seconds you want to wait before you refresh
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- create html file from rss feed (PHP)
- keeping checkbox check when page changes (ASP.NET)
- Unable To Right Click Desktop (Viruses, Spyware and other Nasties)
- How do i load a image on the same page ? (Site Layout and Usability)
- Page Rank on Google? (Search Engine Optimization)
- how to place media page requests on background color (HTML and CSS)
- Page cannot be displayed error (Viruses, Spyware and other Nasties)
Other Threads in the ASP.NET Forum
- Previous Thread: Gridviews/formviews
- Next Thread: Session error in asp net
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formview gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl





