When developing or deploying a Web site you may be confronted with the rather vague error message: ‘CreateResourceBasedLiteralControl’ is not a member of ‘PageName.aspx’.
I encountered this error today while deploying a site to our production environment. The surprise was that I did not see this error when working on my local machine or our development server. I am still not sure why it did work on some machines but not others.
After spending some time tracking down the cause, I found it to be related to conflicts in control Naming on a Web page. This can be due to:
- Conflicts in the control IDs where two or more controls on the page share the same ID
- Setting the Inherits property of the @Page directive to the codebehind partial class of another page
- Setting the codebehind of the page itself to be a partial class for another page.
On reviewing my page it was clear that the site I was trying to deploy had all three of these problems.
I had labels on the page that were set to the same ID, which was confusing the compiler.
Likewise, I had set the Inherits property to a codebehind file that was a partial class and that shared its Class name with the codebehind of another page. This sort of behavior can easily happen if one is putting in place new pages on a Web site by Copying and Pasting the pages.
I was able to resolve the error ( ‘CreateResourceBasedLiteralControl’ is not a member of ‘PageName.aspx’) by:
- Making sure the labels on the page had unique IDs
- Changing the Partial Class name of the codebehind file to the name of the Web page as I had intended
- Updating the Inherits property of the @Page directive to point to the newly renamed Partial Class name intended for the page
The mysterious error ( ‘CreateResourceBasedLiteralControl’ is not a member of ‘PageName.aspx’) vanished once I tracked down and corrected the issues mentioned above.
I hope this description & resolution of the error I encountered today will help people looking for information on the cause of the rather vague error message.