Clashing of two Events
-
For example I am having two controls, textbox and dropdownlist For both the controls autopostback is true. I have written some code in the textbox's textchanged event The problem is -------------- after I do some change in text in the textbox control and directly select an item in the dropdownlist, the page gets vanishes. Actually the whole control in the page gets vanishes!.No other actions can be done in that active browser. We have to finally close the browser and run the page again. If i do the same procedure by clicking somewhere else in the form before selecting an item in the dropdownlist then no problem happens What i feel is that the textchanged event and selectedIndexchanged event is getting fired together.(I am not sure my assumption is right) ------------------------------------------ What is the problem and how can i solve it? ------------------------------------------ The code is server side code all the controls are server controls System.Web.UI.WebControls.Dropdownlist System.Web.UI.WebControls.TextBox I am not creating it dynamically I don't think its the problem of the code in textChanged event bcoz if after changing the text in the textbox if we click anywhere else on the page then click on the dropdownlist, no problem arise Anyway the code for the textchanged event for txtDevelopmentExperience ------------------------------------------ lblMessage.Text = ""; if(txtDevelopmentExperience.Text != "") { RangeValidator objRangeValidator = new RangeValidator(); this.FindControl("Form1").Controls.Add(objRangeValidator); objRangeValidator.ControlToValidate = "txtDevelopmentExperience"; objRangeValidator.Type = ValidationDataType.Double; objRangeValidator.MaximumValue = "10"; objRangeValidator.MinimumValue = "0"; objRangeValidator.Validate(); if(objRangeValidator.IsValid != true) { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Invalid data in DE"; return; } objRangeValidator.ControlToValidate = "txtTestingExperience"; objRangeValidator.Type = ValidationDataType.Double; objRangeValidator.MaximumValue = "10"; objRangeValidator.MinimumValue = "0"; objRangeValidator.Validate(); if(objRangeValidator.IsValid != true) { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Invalid data in TE"; return; } if(txtTestingExperience.Text == "")txtTestingExperience.Text = "0"; txtTotalExperience.Text = Convert.ToString(Convert.ToDouble(txtDevelopmentExperience.Text.Trim()) + Convert.ToDouble(txtTestingExperience.Text.Trim())); ------