473,672 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect when a Component is added to a WebForm

Hello
I have made a component (MyWebForm) that inherits Page. This component
have a method called 'ComponentAdded ' that shows a msgbox if it is in
design mode:

Public Class MyWebForm
Inherits System.Web.UI.P age

Public Sub ComponentAdded( )
If ((Not Me.Site Is Nothing) AndAlso (Me.Site.Design Mode)) Then
MsgBox("Method ComponentAdded" )
End If
End Sub
End Class

I have another component (MyCotrol) that inherits WebControl, that
execute ComponentAdded method when it is added in MyWebForm in design
mode:

<Designer(GetTy pe(DesignerMyCo trol)), ToolboxData("<{ 0}:MyCotrol
runat=server></{0}:MyCotrol>") > _
Public Class MyCotrol
Inherits WebControl
End Class

Public Class DesignerMyCobtr ol
Inherits System.Web.UI.D esign.ControlDe signer

Private control As IurisTextBox

Public Overrides Sub OnSetParent()
Try
control = CType(MyBase.Co mponent, MyControl)
If (control.Page.G etType().Name = "MyWebForm" ) Then
CType(control.P age, MyWebForm).Comp onentAdded()
End If
Catch ex As Exception
MsgBox(ex.Messa ge)
End Try
End Sub

Public Overrides Function GetDesignTimeHt ml() As String
Return "My Control"
End Function
End Class
I want that when MyControl is added in MyWebForm, excute the
ComponentAdded method.
This code not works very well. When MyControl is added, ComponentAdded
method show an exception saying that some object has not been
inicialized.
But if I save the aspx, close it, and open again, the ComponentAdded
method show the msgbox well.
I think that OnSetParent is not the right method to put this code, but
I haven't find any other. Is there any event that execute when a
control is added in a webform?

Thanks
David
Nov 19 '05 #1
0 980

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

Similar topics

1
1980
by: Shawn B. | last post by:
Greetings, If I drop more than one component (custom component) onto a WebForm, is there a way (inside the Component) to identify the instance of the class? For example, Most controls/components have a Name/ID property but there seems not to be one for the Component except in the property editor. Thanks, Shawn
2
1442
by: julk | last post by:
hi im kind of new to C#. i am doing a Ritch text editor dll, for a webform that im going to need. the components runs fine it does all it need to do, and exposes all the properties i need it to expose. the proble that i have is when i drop two of my componentes into the webform there area few conflicts. I am generating all the javaScript functions that do the BOLD,ITALIC for the buttons. since i am doing that if two controls are...
1
1723
by: Lauchlan M | last post by:
Hi. I followed the steps suggested below . . . Say I created my component in the namespace "cld.aspnet.components" - where (filepath) would I look for the dll to add in to the toolbox, and what would be called? Visual Studio.NET has too many places where this file could be - somewhere in my INETPUB, somewhere in the visual studio cache, etc etc. If I know what
9
2074
by: Stan | last post by:
Here is my scenario: Web server ------------ Framework 1.1 Application proxy for the serviced component Component server ------------------- Framework 1.0
4
1453
by: A Traveler | last post by:
Hello all, I have a control i wrote which inherits from asp:label. It worked fine. It extends asp:label with a "For" property which implements the "for" attribute of an html label tag (yes i know the latest framework vers. added this, but i want ot get mine right as a learning exp.). I added a designer class which turns the For property into a dropdown list of the names of all the controls so you can simply pick one. When i added the...
9
7315
by: Don | last post by:
Is there any way to detect when an item has been added to the Items collection of a combobox or listbox? I am inheriting a Combobox and want to validate items before they are added to the combobox, but I can't find anything that will let me do that. - Don
1
4104
by: Kevin R | last post by:
This is one of the weirdest problems I have ever run into. I have had to trim down a bunch of code to give a sample that is more easily readable by those who will view this. Here is the problem: I dynamically add an htmlcheckbox to a webform in the pages render and set the checked value to true. When the page loads, if I remove the check from the checkbox and then submit it, in the submit event the checkbox' checked value is still...
4
4044
by: Dst | last post by:
This is what i'm trying to do: I'm porting a windows app to a web app. I have a webform which will edit some data stored in a database. The data needs to be locked in the database, while editing. On first page load: Create a custom rowlock object and store it in viewstate. When user clicks on edit, retrieve the viewstate object and lock the row in the database.
14
2099
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I tried a google search but could not find anything. I am trying to cause one webpage to reload when a second web page is closed. The second webpage loads data into a session variable and when closed I need to reload the first page loading in the data from the session variable. Since I need to close the sescond form just setting the post back url to the first page on the close button from the second page is not quite what I am looking...
0
8404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8931
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4418
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.