pass control IDs to javascript and css
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.
精彩评论