Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Intercept when my control dropped on a WebForm

Reply
Thread Tools

Intercept when my control dropped on a WebForm

 
 
Vipeo
Guest
Posts: n/a
 
      01-12-2006
Hi All!

I need to intercept the event when my control dropped on a WebForm (or
manually added by changin page's source HTML). I know about
IComponentChangeService and its ComponentAdding event, but in which class
should I use it?

Thank you for any help.
 
Reply With Quote
 
 
 
 
Vipeo
Guest
Posts: n/a
 
      01-12-2006
Sorry, figured this out.

"Vipeo" wrote:

> Hi All!
>
> I need to intercept the event when my control dropped on a WebForm (or
> manually added by changin page's source HTML). I know about
> IComponentChangeService and its ComponentAdding event, but in which class
> should I use it?
>
> Thank you for any help.

 
Reply With Quote
 
 
 
 
Ian
Guest
Posts: n/a
 
      01-12-2006
Could you post it here then?

 
Reply With Quote
 
Vipeo
Guest
Posts: n/a
 
      01-12-2006
To get this "extra" functionality in design-time for your control, you need
to have a designer (System.Wen.UI.Design.ControlDesigner), and don't forget
to apply the DesignerAttribute to your control. The designer's code requests
a IComponentChangeService and subscribes to its ComponentAdding event. That's
all.

So, in my case the designer looks like this:

class CMSWebPageDesigner : ControlDesigner
{
private IComponentChangeService changeService = null;

private void InitializeServices()
{
this.changeService = GetService(typeof(IComponentChangeService))
as IComponentChangeService;
if (changeService != null)
{
changeService.ComponentAdding += new
ComponentEventHandler(ChangeService_ComponentAddin g);
}
}

void ChangeService_ComponentAdding(object sender, ComponentEventArgs
e)
{
if (e.Component is CMSWebPage)
throw new ApplicationException("CMSWebPage component is
already on the page.");
}

#region Overrides

public override bool AllowResize
{
get
{
return false;
}
}

private DesignerVerbCollection designTimeVerbs;
public override DesignerVerbCollection Verbs
{
get
{
if (null == designTimeVerbs)
{
designTimeVerbs = new DesignerVerbCollection();
designTimeVerbs.Add(new DesignerVerb("Page Setup...",
new EventHandler(this.OnPageSetup)));
}
return designTimeVerbs;
}
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.changeService != null)
{
// Unhook event handlers.
this.changeService.ComponentAdding -=
new ComponentEventHandler(
ChangeService_ComponentAdding);
}
}

base.Dispose(disposing);
}

public override void Initialize(IComponent component)
{
if (!(component is CMSWebPage))
throw new ArgumentException("Must be a CMSWebPage component");
base.Initialize(component);

InitializeServices();
}

#endregion

private void OnPageSetup(object sender, EventArgs e)
{
PageDesignerEditor editor = new PageDesignerEditor();
editor.EditComponent(Component);
}
}


"Ian" wrote:

> Could you post it here then?
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Another webform without closing the current webform ? Luqman ASP .Net 2 04-11-2007 02:43 AM
Moving value from popup Webform to main Webform? =?Utf-8?B?Vk1J?= ASP .Net 1 10-09-2006 05:15 PM
Using one webform to set a value on another webform =?Utf-8?B?bXN1aw==?= ASP .Net 1 07-12-2006 07:23 PM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Including WebForm Image Control in a Webform Table Control titof ASP .Net 0 07-24-2003 01:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57