DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sat, 21 Jul 2007 20:56:58 -0400,    posted on: microsoft.public.dotnet.framework.aspnet.webcontrols        back       

Thread Index
  1    Monty am
          2    (Walter Wang [MSFT])
          3    David R. Longnecker am
          4    Monty am


Style not applied until refresh...?   
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
Date:Sat, 21 Jul 2007 20:56:58 -0400   Author:  

RE: Style not applied until refresh...?   
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 (wawang@online.microsoft.com, 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.
Date:Mon, 23 Jul 2007 01:26:46 GMT   Author:  

Re: Style not applied until refresh...?   
http://msdn2.microsoft.com/en-us/library/ms178472.aspx

Try tossing it in Page_Init or creating an event for that stage of the life 
cycle.  If you use Page_Load, your controls are already built and will be 
populated from state; rendering is even further down the chain--when your 
controls are streamed out to the HTTP stream.

Page_Init is usually where style information and such is applied. :D

HTH.

-dl

--
David R. Longnecker
http://blog.tiredstudent.com


> 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
> 
Date:Mon, 23 Jul 2007 17:02:59 +0000 (UTC)   Author:  

Re: Style not applied until refresh...?   
Duh! Of course. Thanks David, that is exactly correct.
Date:Tue, 24 Jul 2007 13:57:12 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us