Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8997903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:57:07+00:00 2026-06-15T23:57:07+00:00

I’ve recently added an UpdatePanel to a single webpage which renders different usercontrols on

  • 0

I’ve recently added an UpdatePanel to a single webpage which renders different usercontrols on button clicks. I’m struggling with a problem where i’m adding inline styling into the header dynamically with Header.Stylesheet.CreateStyleRule – the problem is that it doesn’t get inserted on partial postbacks and it does make sense. This is obviously because it’s a partial postback and the header is only being rendered when the page loads the first time.

The styling is being added by the following methods, which gets the styling from a database:

Private Sub InitializeStylesheet(ByVal ButtonId As Integer)
    Dim CSSStylesheet As Stylesheet = StyleBackend.GetStylesheets(ButtonId)
    Dim IdClassList As List(Of StyleIDClass) = StyleBackend.GetStylesheetsStyleIDClass(CSSStylesheet.StylesheetID)
    'Iterates through the cssidclass
    For Each cssidClass In IdClassList
        Dim styleItems As List(Of StyleItem) = StyleBackend.GetStyleItemsByIDorClass(cssidClass.StyleIDClassID)
        Dim cssString As String = Nothing
        For Each StyleItem As StyleItem In styleItems
            cssString += StyleItem.Property & ":" & StyleItem.Value & ";"
        Next
        'Iterates all cssitems which belongs to a cssidclass
        Me.Header.StyleSheet.CreateStyleRule(New CustomStyle(cssString), Nothing, cssidClass.ClassOrID)
        Me.Header.ViewStateMode = UI.ViewStateMode.Disabled
    Next
End Sub

I’ve been googling my ass off trying to get this to work, but it seems to be impossible.

This msdn article literal says that it is impossible to do what i’m trying to do.
http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlhead.stylesheet.aspx

Adding styles or style rules programmatically during asynchronous postbacks is not supported. When you add AJAX capabilities to an ASP.NET Web page, asynchronous postbacks update regions of the page without updating the whole page. For more information, see Microsoft Ajax Overview.

Does anyone have a suggestion or alternative way of doing this?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:57:08+00:00Added an answer on June 15, 2026 at 11:57 pm

    One solution is just to include the styles in your main stylesheet(s) rather than modifying them dynamically. Even if they are data-driven, you could output them with the main page via an HTTP handler if the total list isn’t too large.

    Alternatively (and probably more efficiently), you can return the style data to the client as a string and process it there.

    You can listen for the EndRequest event on the client script manager:

    function endRequest(){
        // look at the updated DOM     
    }
    
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
    

    Perhaps the following sequence:

    • Initiate async postback
    • Render the styles to a hidden field inside the UpdatePanel
    • On endRequest, examine the DOM to see if it contains a hidden field with styles (based on naming convention, data attributes, or just ID)
    • Grab the values out of the hidden field and add them to the page’s style rules using JavaScript
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tracked down a weird MySQL problem to the two different ways I was
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.