开发者

Can we declaratively set the Style property of a web control?

I’ve noticed that on aspx page IntelliSense doesn’t display the Style property of a web control, even t开发者_Python百科hought the control does have a Style property. Does that mean we shouldn’t declaratively set the Style property:

<asp:TextBox ID="UserName" Style="color:Green; padding:0px; margin:0px;" runat="server"></asp:TextBox>


Style translates to the client-side style property; it's actually a CssStyleCollection collection of styles. It doesn't display the style property directly, but once you type style=" it should start showing you the CSS styles that are available to you.


If you have to set these styles in the same file as your html then it's much better to use an embedded style that targets the ID of your control. The best solution, however, is to reference an external stylesheet (css) that contains your styles.

For example:

<style type="text/css">
  #UserName {color:Green; padding:0px; margin:0px;}
</style>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜