-
January 21st, 2009, 01:11 PM
#1
[RESOLVED] Server Controls and Styles
I'm working on creating a server control. There will be a bit of client side actions. Mostly, javascript will change the style when the mouse moves over parts of the control. The aspect I can't seem to find any info on is how to define the styles.
For the javascript it simple, just call RegisterClientScriptBlock(). However, I can't find a similar function for writing css. I suppose I could write it in the Render() function. However, that'll write the css once for each instance of the control on the page. Maybe, I could prefix the style names with the control id so at least each set of styles will have unique names.
I suppose another approach is to not write css styles to the page and instead have javascript change each style property one at a time instead of just changing the class name. However, this approach just seem like a bad approach.
Could someone explain or direct me to a reference to exlains the correct way to do this?
Thanks,
-
January 28th, 2009, 04:11 PM
#2
Re: Server Controls and Styles
I figured out a way to do this.
Code:
Dim myStyle As New Literal()
myStyle.Text = "<style type=""text/css"">"
myStyle.Text += My.Resources.StyleSheet
myStyle.Text += "</style>"
myStyle.ID += UniqueID + "_myStyle"
If Page.Header.FindControl(myStyle.ID) Is Nothing Then
Page.Header.Controls.Add(myStyle)
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|