I have the below error message in my asp.net website when i replaced the textbox and put dropdown and named the dropdown id same as textbox id.
The value from the drop down should be taken and put in a email body and will be received as mail when i click on the submit button.
Below is the error i am getting when i click on the submit button.
System.InvalidCastException: Unable to cast object of type ‘System.Web.UI.WebControls.DropDownList’ to type ‘System.Web.UI.WebControls.TextBox’. at WebApplication1._Default.collectEmailBodyText() in C:\v1.5_production_05June09\Default.aspx.vb:line 213
Please help me !
It sounds like the code was not recompiled once the change was made or that if it was recompiled that the change was not picked up by the designer file.
the designer file has references to each control placed on the ASPX page, so it will have some line like
protected global::System.Web.UI.WebControls.TextBox myInput
when you chage it to a drop down list, the designer should change to:
protected global::System.Web.UI.WebControls.DropDownList myInput
If this didn’t happen you will run into errors. At run time, the controls on the ASPX page are instantiated but if the underlying type differes then you will get an error as soon as you try to access the control.