[RESOLVED] Server Controls and Styles
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [RESOLVED] Server Controls and Styles

  1. #1
    Join Date
    Oct 2006
    Posts
    181

    [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,

  2. #2
    Join Date
    Oct 2006
    Posts
    181

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center