开发者

pass control IDs to javascript and css

开发者 https://www.devze.com 2023-02-10 16:24 出处:网络
I have a user control (the 开发者_如何学Goone which is .ascx), it has lots of asp:Panel, asp:Image and asp:Button elements. I need to pass client IDs to javascript and css. Right now the javascript an

I have a user control (the 开发者_如何学Goone which is .ascx), it has lots of asp:Panel, asp:Image and asp:Button elements. I need to pass client IDs to javascript and css. Right now the javascript and css are included in the markup of .ascx control. So what is the best way to pass the client IDs?


In your javascript in the .ascx control you can use something like the following:

var panelId = '<%= MyPanel.ClientId %>';

That will render the panel's client id as a string into the panelId variable in javascript.

For css, I recommend just using the CssClass property when possible and to avoid inline css.

0

精彩评论

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