欢迎光临
我们一直在努力

里面是对一个body的属性进行server的一些设定,不过可以衍生到其他的一些htmlcontrol新手看看,或者有点…-.NET教程,Asp.Net开发

建站超值云服务器,限时71元/月

the first code snippet below uses the attributes collection of the <body> tag (implemented as an htmlcontrol object) to reference its standard html attributes. this method gives you programmatic access to any of the html attributes that you normally hard-code into your <body> tag.

the second method uses the style object property of the htmlcontrol object. by making calls to the style object propertys add method, you can add custom styles to your <body> tag. these are implemented as an inline style tag when it is rendered to the browser.
because of this, you may want to research whether the style you are going to implement is compatible with the browser you are targeting.

the techniques used here can be used to set the properties of any html control that does not have a server control equivalent. an example would be the <p> tag.

sample code 1: use the "attributes" collection of the body tag

<%@ page language="c#" %>

<script language="c#" runat="server">
    protected void page_load(object sender, eventargs e) {
        body.attributes["bgcolor"] = "#cccccc";
    }
</script>

<body id="body" runat="server">
    this is the body text.
</body>

sample code 2: use the "style" collection of the body tag

<%@ page language="c#" %>

<script language="c#" runat="server">
    protected void page_load(object sender, eventargs e) {
        body.style.add("background-color","#cccccc");
    }
</script>

<body id="body" runat="server">
        this is the body text.
</body>

notes:
be sure to add the runat="server" attribute to your body tag and give it an id

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 里面是对一个body的属性进行server的一些设定,不过可以衍生到其他的一些htmlcontrol新手看看,或者有点…-.NET教程,Asp.Net开发
分享到: 更多 (0)