how to set property of web control to constant

B

Bob

Ok, I have a custom web control (a server control) and I
want to set a property on this control equal to a
constant that exists in my code behind. Is there a nice
way to do this by putting code into my aspx file (it's
nice to see the properties all in one place). In ASP I
think you could do <%= somevalue %>...

Thanks!

Bob
 
T

Teemu Keiski

Hi,

if you have that value in code-behind, you'd assign the value to the
control's property via code-behind member and if possible (control loaded)
before ViewState tracking starts (TrackViewState is called) in practise in
OnInit. This way setting the property won't cause value to be stored in
ViewState (if control property uses ViewState as underlying storage), but it
is considered as initial value (specified on every request).

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


Ok, I have a custom web control (a server control) and I
want to set a property on this control equal to a
constant that exists in my code behind. Is there a nice
way to do this by putting code into my aspx file (it's
nice to see the properties all in one place). In ASP I
think you could do <%= somevalue %>...

Thanks!

Bob
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top