开发者

Change <body> to <body id"something" runat="server'>

开发者 https://www.devze.com 2023-03-15 20:25 出处:网络
We have a huge website with main.master that is used in a lot of places.. If I change thetag to runat=\"server\", would any other regular stuff continue working or it would not get affected if I chang

We have a huge website with main.master that is used in a lot of places.. If I change the tag to runat="server", would any other regular stuff continue working or it would not get affected if I chang开发者_开发问答e it?

Thank you


Yes, everything will continue to work. You will then also be able to affect the tag in code.


Yes you can add runat="server" to the body tag. Be sure to define the ID clearly, and you may need to reference it yourself within your code since it's an HTML element not an ASP.NET control


only javascript wont work if you put runat="server", when I say javascript i mean on those method that search for body by id, because when you add runat="server" your id won't be "something" it will be autogenerated string which is showing path to your body. for example ctl0_master_something. but before you do it just add "=" before your id"something" (id="something")


The javascripts and css references may fail to work depending on your referencing pattern. At places with runat tag the reference using ~ sign will work fine. At places where you do not use runat="server" then use this kind of referencing and it should work fine:

<link rel="stylesheet" type="text/css" href='<%= ResolveUrl("~/css/style.css") %>' />
<script type="text/javascript" src="<%= ResolveUrl("~/js/jquery-1.3.2.min.js") %>"></script>
0

精彩评论

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