Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / June 2004

Tip: Looking for answers? Try searching our database.

Addin: Access ASPX Page ProjectItem as Web.UI.Page object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James Doran - 21 Jun 2004 14:42 GMT
Hi,

I'd like to access an ASPX page ProjectItem as a System.Web.UI.Page object
from within an Add-in project.

Could anyone please, please shed any light on this subject?

Thanks,

James
Carlos J. Quintero [MVP] - 21 Jun 2004 15:28 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.