Resolve Asp.Net As?X HTML Warnings

If you’ve ever added your own HTML attributes to Asp.Net controls, you might be annoyed by the warnings in your Task List that say something like the following:

C:\\Inetpub\wwwroot\BlahBlah\\SomePage.ascx(72): Could not find any attribute 'foo' of element 'CheckBox'

Several months ago I found a citation to a solution, but when I had occassion to need it again this week, I couldn’t recall the solution, nor could I find the original citation. I did find a lot of useless suggestions like turn off the HTML checking. Yeah, that’s brilliant. Turn off errors and warnings–that’ll fix those bugs. Sheesh. As if it’s unlikely one might every mistype an attribute.

It’s far better to resolve a development-time error or warning than ignore it. Especially since it is easy once you know what to look for.

Anyway, the solution I’ve found is to add my custom attributes to the Asp.Xsd file (after making a backup of the file, of course), which, on my system, is located here:

c:\\program files\\microsoft visual 2003\\common7\\packages\\schemas\\xml\\asp.xsd

You’ll want to make a copy of the file before you change it, naturally. However, if you follow the examples in the file, you shouldn’t have much trouble making simple changes such as adding new attributes. Here’s an example of how I’ve added a custom attribute called RequiredValue to the CheckBox control:

Asp.Xsd Example

Why Microsoft made it so damned difficult is beyond my understanding.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s