BusinessRx Community

Dedicated to the advancement of software, technology and the people who devote their lives to it.

Welcome to BusinessRx Community Sign in | Join | Help
in Search

BusinessRx Reading List

These blog entries are written by industry experts and leaders. We consider this content to be a good read for any software developer or web technologist.

The Confusing "Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox'" Compilation Error

When building an ASP.NET 2.0 application in Visual Studio 2005, I received the following error: “Cannot implicitly convert type 'string' to 'System.Web.UI.WebControls.TextBox'”. No line number, no source page informing me where to begin my search. And it had been a while since my last build so there was a lot of code and markup that could be the source of the problem.

A quick Google search turned up this entry by Sam Judson:

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.

And that was the cause of my problem, a TextBox with an ID of Title. Once the ID was changed to something else, the project compiled without error. For more on the Page.Title property new to ASP.NET 2.0, see Dynamically Setting the Page's Title in ASP.NET 2.0.

Published Friday, January 26, 2007 11:48 AM by Scott on Writing

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems
'