With Windows Forms you would cast Window.Object to IDesignerHost and then
you have IDesignerHost.RootComponent that you cast to Form.
But Window.Object return Nothing for Web Forms. In the thread "IDesignerHost
interface, WebForms and Add-in" of 16-JUN in this group someone suggested a
possible approach but I am not sure if it worked.

Signature
Carlos J. Quintero (Visual Developer - .NET MVP)
FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET
addins:
http://groups.yahoo.com/group/vsnetaddin/ (free join)
> Hi,
>
[quoted text clipped - 6 lines]
>
> James
James Doran - 21 Jun 2004 16:42 GMT
Carlos,
Many thanks for your reply, I really appreciate the response.
Unfortunately, I've read the thread from the 16th of June that you
mentioned, and the problem was not solved. This must be possible, there's
just seems to be a severe lack of documentation for VS.NET extensibility.
Do you have any other ideas, or possibly point me in the correct direction?
Thanks,
James
> With Windows Forms you would cast Window.Object to IDesignerHost and then
> you have IDesignerHost.RootComponent that you cast to Form.
[quoted text clipped - 13 lines]
> >
> > James
Adam Friedman - 22 Jun 2004 02:52 GMT
See my last post on that thread. It works when I'm not being lazy and giving
half-assed instructions :->
Note that you'll probably need the VSIP SDK for this (even if you're only
making an add-in) but you might be able to get away with creating your own
definition of IOleServiceProvider instead...
> With Windows Forms you would cast Window.Object to IDesignerHost and then
> you have IDesignerHost.RootComponent that you cast to Form.
[quoted text clipped - 13 lines]
> >
> > James
James Doran - 22 Jun 2004 16:11 GMT
Adam,
You ARE the man! I've been trying to find out how to do this for days on
end, and am really pleased it's now working. In order to save other people
time looking for the other thread that you posted to, I'll include the
information here:
============================================================
Add a reference to the following two assemblies:
+ Microsoft.VisualStudio.Designer.Interfaces
+ Microsoft.VisualStudio.OLE.Interop
These are available by downloading "VSIP 7.1 Extras" from Microsoft
I also added a reference to:
+ System.Design
----------------------------------------------------------------------------
--------------
Add the following code to the add-in:
----------------------------------------------------------------------------
--------------
DTE dte = (DTE)GetService(typeof(DTE));
HTMLWindow hw = dte.ActiveWindow.Object as HTMLWindow;
object o = hw.CurrentTabObject;
IOleServiceProvider oleSP = o as IOleServiceProvider;
System.Web.UI.Page oPage;
IntPtr pObject;
Guid sid = typeof(IVSMDDesigner).GUID;
Guid iid = typeof(IVSMDDesigner).GUID;
int hr = oleSP.QueryService(ref sid, ref iid, out pObject);
NativeMethods.ThrowOnFailure(hr);
IDesignerHost designerHost = null;
if (pObject != IntPtr.Zero)
{
try
{
designerHost = Marshal.GetObjectForIUnknown(pObject) as
IDesignerHost;
oPage = (System.Web.UI.Page)designerHost.RootComponent;
}
finally
{
Marshal.Release(pObject);
}
}
============================================================
Thanks for taking the time to reply Adam.
James
> See my last post on that thread. It works when I'm not being lazy and giving
> half-assed instructions :->
[quoted text clipped - 23 lines]
> > >
> > > James
Adam Friedman - 25 Jun 2004 03:05 GMT
You're welcome :-)
> Adam,
>
[quoted text clipped - 79 lines]
> > > >
> > > > James