473,379 Members | 1,260 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

how to set property of web control to constant

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
Nov 18 '05 #1
1 1646
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
"Bob" <an*******@discussions.microsoft.com> wrote in message
news:14*****************************@phx.gbl...
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
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Nicolas | last post by:
How can I simply do this. string tAlign; tAlign="Left"; TextBox textbox1 = new TextBox(); textbox1.TextAlign = tAlign; I know that it shoul be like "textbox1.TextAlign =
5
by: bbrik | last post by:
Hi, I'm doing a control that has a custom color property and i want to set a default value. I tried several combinations using the DefaultValue atribute but it didn't work. It must be a...
2
by: Lance | last post by:
I want to be able to reset a complex property in a PropertyGrid. I know that for properties that are ValueTypes you can include System.ComponentModel.DefaultValue in the declaration of the property....
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
2
by: Steve | last post by:
Hi, I would like to set the default value of a property on my control by: but can't because SystemColors.WindowText is not a constant. Microsoft controls do it, can I - is there a work round?...
27
by: sklett | last post by:
I just found myself doing something I haven't before: <code> public uint Duration { get { uint duration = 0; foreach(Thing t in m_things) { duration += t.Duration;
6
by: Robert | last post by:
Quick question about the visible property on a form control. I have a label that displays a message if a certain criteria is met. By default the label is visible. I want access to compare a...
9
by: Eric | last post by:
Hi Everyone, I'm writing a UserControl that exposes a property of the type System.Drawing.Image, like this: Public Property DefaultImage() As Image Get Return propDefaultImage End Get...
1
by: --== Alain ==-- | last post by:
Hi, I've created a simple class "GridLines" having 3 properties (Prop1, Prop2, and Prop3). in my custom control, i've created a property based on this class "GridLines". To show the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.