473,402 Members | 2,072 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,402 software developers and data experts.

Not running init code at design time

Hello all

I am writing a Web Custom Control that extends the CheckboxList control

For performance reasons I do some one-time resource management in the (static) constructor. This requires access to the Server object, which is not available at design time. Therefore, when I drop the control on a web form, I get "error creating control"

Someone suggested creating a custom designer to provide a different interface at design time. I tried that but the problem is that the component is instantiated first and then passed to my designer class, meaning that the problem occurs before my designer can do anything about it

How can I get some code in my constructor to not run at design time

Clarenc

Nov 16 '05 #1
1 1655
Clarence,

You can detect whether the code is running in design mode by verifying
whether there is a current HttpContext. e.g.:

protected bool DesignMode
{
get
{
return HttpContext.Current == null;
}
}

HTH,
Nicole
"Clarence" <an*******@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
Hello all,

I am writing a Web Custom Control that extends the CheckboxList control.

For performance reasons I do some one-time resource management in the
(static) constructor. This requires access to the Server object, which is
not available at design time. Therefore, when I drop the control on a web
form, I get "error creating control".

Someone suggested creating a custom designer to provide a different
interface at design time. I tried that but the problem is that the
component is instantiated first and then passed to my designer class,
meaning that the problem occurs before my designer can do anything about
it.

How can I get some code in my constructor to not run at design time?

Clarence

Nov 16 '05 #2

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

Similar topics

4
by: Anatoly | last post by:
Put any control on web page. create Init event for ths control. Write Response.Write("here") inside this event. Compile\build\run. I never saw "here" string appear on web page. Why???
8
by: TS | last post by:
Hi, i have inherited a page from another user. The page is the target frame in a frameset. for some reason the whole page runs twice (page_load, init, etc. all run twice) I can't figure out how...
6
by: seb | last post by:
Hi, I am using pygtk for the first times. I am wondering what would be the best "pattern" to interface pygtk with a thread. The thread is collecting informations (over the network for...
11
by: sunil | last post by:
Dear All, I have created a .Net service in 2.0 and running it on a machine that has a Quad Processor. It is failing with the following error. "Error 1053: The service did not respond to the start...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.