473,385 Members | 1,919 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,385 software developers and data experts.

ASP.NET WebControl only allow one instance of control

115 100+
I created a custom webcontrol that could be used inside of other controls. It only needs to be rendered once on any page that uses it no matter how many other controls call for it.

How can I prevent the web control from rendering if another is already on the page?

I tried
Expand|Select|Wrap|Line Numbers
  1. Page.FindControl("controls_static_id") == null
inside of the Render method but that didnt work.
Aug 7 '08 #1
3 1338
Frinavale
9,735 Expert Mod 8TB
Could you please clarify the context in which you are using the WebUser?
Your approach is not going to be easy to implement. If you provide more information on what the web user control does and how it should be used we may be able to suggest a different approach to your problem.

-Frinny
Aug 14 '08 #2
ShadowLocke
115 100+
Sorry, I forgot about this post. The control is a custom tooltip control. What I ended up doing was taking a look at how the Ajax.Net ScriptManager control did it. soo..

Expand|Select|Wrap|Line Numbers
  1.         private Boolean ToolTipExists()
  2.         {
  3.             return (Page.Items[typeof(u_tooltip)] != null);
  4.         }
  5.  
  6.         protected override void OnInit(EventArgs e)
  7.         {
  8.             RenderMe = !ToolTipExists();
  9.             Page.Items[typeof(u_tooltip)] = this;
  10.             ...
worked for me
Could you please clarify the context in which you are using the WebUser?
Your approach is not going to be easy to implement. If you provide more information on what the web user control does and how it should be used we may be able to suggest a different approach to your problem.

-Frinny
Aug 20 '08 #3
Frinavale
9,735 Expert Mod 8TB
Thanks for taking the time to post your solution!

:)
Sep 5 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Owatona | last post by:
Hi to all... I have 3 classes derived from webcontrol. I the first i have two dropdownlist, in the second i have some buttons, and the third its the webcontrol that are instanciate the two...
1
by: Marri Suliez | last post by:
Does anyone know how the Style property of the WebControl class persists between calls as if it's added to the ViewState? CssStyleCollection is not serializable. The following scenario leads me...
0
by: Lucas, Todd | last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing for a Menu. I've been at it for about 3 weeks now, and can't seem to get around this problem. So I'm hoping that someone...
9
by: kw | last post by:
What is the proper way to get the element ID for a client script? For example, suppose in the WebControl: TextBox t=new TextBox; t.ID=this.ClientID+"X"; .... Then elsewhere we want to access...
3
by: Hadar | last post by:
Hi, I'm still a little bit confused with how managing a webcontrol state over postbacks... Should I use the form's post values to populate the control on the server side when possible, or...
2
by: Ersin Gençtürk | last post by:
hi , I am trying to add a usercontrol to the control collection of a webcontrol but I get "Object reference not set to an instance of an object." errors.On the other hand , by changing the code...
0
by: Henrik Stidsen | last post by:
I need to get the HTML output from a webcontrol as a string instead of it being rendered on the page. I have the following code: Dim SiteMapSource As New SiteMapDataSource() Dim TreeView1...
4
by: jay | last post by:
Greetings ASP.NET 2.0 I'm developing a webcontrol. The class will ultimately end up in a webcontrols DLL, but for development purposes, I want to put the class in a code-behind. This is so...
1
by: brandonjack007 | last post by:
I am looking for a date custom webcontrol that extends from System.Web.UI.WebControls The control will expose the following Properties to the page that implements it Date (datetime) Month...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.