James Posted January 3, 2003 Posted January 3, 2003 I am having problems initializing my custom user control. I keep getting the following error: Specified cast is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Specified cast is not valid. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [invalidCastException: Specified cast is not valid.] WylePricingSystem.HeaderInfo.Page_Load(Object sender, EventArgs e) in \\station5\wwwroot$\WylePricingSystem\NewLaborEst.aspx.vb:105 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain() I've attached my code. Can someone please help me? Thanks, James Quote
*Gurus* divil Posted January 3, 2003 *Gurus* Posted January 3, 2003 You didn't attach your code. Not that I have time to download attachments - can you paste the line in question, and perhaps the ones before and after it? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
James Posted January 3, 2003 Author Posted January 3, 2003 I forgot to attached the file.custom.txt Quote
James Posted January 3, 2003 Author Posted January 3, 2003 I get the error on the last line below. Protected WithEvents Head As PriceHeader Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' ' Dim sScript As String Head = DirectCast(FindControl("Header1"), PriceHeader) Quote
*Gurus* divil Posted January 3, 2003 *Gurus* Posted January 3, 2003 Ok, then that error simply means that the control "Header1" is not a PriceHeader. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
James Posted January 3, 2003 Author Posted January 3, 2003 "Header1" is the id for my custom control. How do I make "Header1" a PriceHeader? James Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.