|
|
|
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:
|
|
|