By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,728 Members | 1,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,728 IT Pros & Developers. It's quick & easy.

Rules for using HTML tag attributes in ASP tags?

P: n/a
I'm wondering if there are general rules for the use of HTML attributes with ASP tags?

For example, one can set an id for an asp:DataGrid and it will show up as the id for
the resulting HTML table.

So then can one set, say, a class for an asp:DataGrid and all other asp tags that map
one-to-one to HTML tags and have it pass thru? I'd like to use class in particular to
map the resulting generated HTML to CSS names. I just tried this and this worked. The
CLASS showed up with the table tag as an attribute. Is it usually supposed to work?

Also, asp:DataGrid maps to table. So then can one just put cellpadding or other legal
attributes of a table as attributes for an asp:DataGrid attribute and have them pass
thru?

Doing this sort of thing with HTML tag attributes with ASP.Net tags seems to work.
But I'm wondering if this is considered normal practice or practice to avoid except
in rare cases or what?
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
For the most part, unrecognized ASP.Net attributes are simply added to the
Attributes collection and outputted as-is. It can be useful in a number of
situations, and I've certainly done it now and again. However, sometimes
the two conflict. For example, specifying onClick on many controls invokes
the server-side method, hence you need to use xxx.Attributes.Add("OncClick",
"blah();"); in code. Never done it with class (which is a C#/vb.net
keyword), but you should first check if there's an asp.net control
alternative, such as cssClass

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Randall Parker" <NOtechieSPAMpundit_please@future_avoidjunk_pundit .com>
wrote in message news:ex**************@TK2MSFTNGP09.phx.gbl...
I'm wondering if there are general rules for the use of HTML attributes
with ASP tags?

For example, one can set an id for an asp:DataGrid and it will show up as
the id for the resulting HTML table.

So then can one set, say, a class for an asp:DataGrid and all other asp
tags that map one-to-one to HTML tags and have it pass thru? I'd like to
use class in particular to map the resulting generated HTML to CSS names.
I just tried this and this worked. The CLASS showed up with the table tag
as an attribute. Is it usually supposed to work?

Also, asp:DataGrid maps to table. So then can one just put cellpadding or
other legal attributes of a table as attributes for an asp:DataGrid
attribute and have them pass thru?

Doing this sort of thing with HTML tag attributes with ASP.Net tags seems
to work. But I'm wondering if this is considered normal practice or
practice to avoid except in rare cases or what?

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.