c# - Use of @class with custom class on MVC Html.ActionLink with HtmlAttributes failing -
i've read through links here find these techs. no exact match see, so...
i have custom css class, i'm trying apply using htmlattributes
containing @class
, never overwrites underlying css (in same file) <a>
. deleting default css a
fails. contrast, when use @style
in htmlattributes
, works.
i'm assuming there's subtle boneheaded mistake in syntax.
nb: goal make links buttons. i'll settle removing underlining proof of concept.
here razor markup works, quote
object contains text in property, , id used against model / db:
@html.actionlink(quote.quotecontent.supplybytesasstring(), "readquote", new {quotecontentid = quote.quotecontentid }, new { @style = "text-decoration: none;" })
fine. dumps underlining. following doesn't work, , can't tell why. actual css comes last here. dumps underlining among other things, none of applied.
@html.actionlink(quote.quotecontent.supplybytesasstring(), "readquote", new { quotecontentid = quote.quotecontentid }, new { @class = "quote" })
this css right now, relevant sections (?), microsoft's default , mine. i've tried every single option various sources recommended quotes
class... .quote
a
, a .quote
, .quote
itself, colons, else find or dream up. maybe missed something, ugh.
anyway, i'd love know i'm doing wrong before head explodes. thanks...
a { color: #333; outline: none; padding-left: 3px; padding-right: 3px; text-decoration: underline; } a:link, a:visited, a:active, a:hover { color: #333; } a:hover { background-color: #c7d1d6; } a.quote { border: 1px inset #808080; color: #333; outline: none; padding-left: 3px; padding-right: 3px; text-decoration: none; } a.quote:active, a.quote:hover { background-color: #ffff66; } a.quote:link, a.quote:visited { color: #333; background-color: #00cc66; }
< end of question >
thanks idlerboris comment. checked out issue suggested (including viewing source markup browser) , css was attaching.
so, turns out did make boneheaded mistake feared, , long before point posted here.
in short, css doesn't work because don't have .quote
defined in css file. naturally, started .quote
defined standalone, error somewhere @ time (probably on in razor) must have confused me , got hasty fixing instead of doing right.
if there's syntax lesson here, it's obvious one: don't try use style in combo-selector css syntax unless it's defined itself.
another pointer: don't forget refresh in browser when debug , haven't edited page content. caching vex you. not root problem here, forgetting caching didn't help.
the main lesson here clearly: code slowly, prefer looking things on guessing, , no matter what, change one variable in each experiment! sigh
Comments
Post a Comment