Strange ASP.Net 2.0 Error

While developing a new web site using ASP.Net 2.0 recently I came across this strange error on compilation.

Cannot implicitly convert type ‘string’ to ‘System.Web.UI.WebControls.TextBox’

It took my ages to work out what the hell was the problem, which string was it trying to convert?

The problem occurred because of the new Page.Title property. I had a TextBox whose ID was also set to Title. It was therefore trying to convert the string in the Page declaration into a textbox – not gonna work! This Title property is new for ASP.Net 2.0 so you might want to watch that one in your apps.

5 Replies to “Strange ASP.Net 2.0 Error”

  1. Hey, you saved my day!!!!

    When I copied the error into the Google search I felt this would hardly get me anywhere, but yeah – here I am and my code works. Just changed the ID of my textBox to ‘TitleTxtBox’ instead of ‘Title’ and it worked. I know it would have taken me ages to figure this out, too. Thank you!!! Have you notified Microsoft. I think title textboxes will appear in a lot of forms and give people a strong head ache.

Comments are closed.