Style not applied until refresh...?

Discussion in 'ASP .Net Web Controls' started by Monty, Jul 22, 2007.

  1. Monty

    Monty Guest

    Hi, I have a user control in which I set some style properties
    programmatically, like so:

    divMain.Style.Add("width", Me.PixelWidth.ToString & "px")
    Dim iInnerWidth As Integer = Me.PixelWidth - 2
    ddlCategory.Style.Add("width", iInnerWidth.ToString)
    ddlLocation.Style.Add("width", iInnerWidth.ToString)

    I've tried setting these style attributes during the page_load and
    page_prerender events of the user control, but for some reason the styles do
    not seem to be applied until there has been a postback on the page, and
    suddenly everything "pops" to the correct width. What am I missing here?
    Thanks in advance...

    Monty
     
    Monty, Jul 22, 2007
    #1
    1. Advertising

  2. Hi Monty,

    Where are you putting these code? Normally, if you change properties
    *after* Render, the changes will not be shown on the page until next
    postback.


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], Jul 23, 2007
    #2
    1. Advertising

  3. Monty

    Monty Guest

    Duh! Of course. Thanks David, that is exactly correct.
     
    Monty, Jul 24, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Angel
    Replies:
    1
    Views:
    376
    Raja Balaji R
    Jan 2, 2004
  2. Rob Nicholson
    Replies:
    3
    Views:
    772
    Rob Nicholson
    May 28, 2005
  3. =?Utf-8?B?QW1pdA==?=

    Style Sheet not getting applied to content page

    =?Utf-8?B?QW1pdA==?=, Dec 10, 2006, in forum: ASP .Net
    Replies:
    8
    Views:
    521
    =?Utf-8?B?QW1pdA==?=
    Dec 11, 2006
  4. Mete Akalýn
    Replies:
    1
    Views:
    419
    Mete Akalýn
    Jul 25, 2003
  5. Replies:
    0
    Views:
    102
Loading...

Share This Page