Ian (Fluxtah) Warwick's blog RSS 2.0
# Saturday, October 04, 2008

All last night till 2am and when I could find the time today I have been having some great fun with developing a configuration wizard for a SnippetCallback control that is part of my Ajax Snippets project.

I wanted the user to select a webservice and then select a method from that service, but there did not seem to be an easy way to get at the web projects files during design-time, at least thats what I initially thought.

It turns out that there is an IWebApplication interface that can be got at by using the GetService method of a component sited in design mode, this then allows you to get at a project item. In my case I needed to get at the asmx file and pull out the type name of its associated code-behind file so I could get a list of methods.

This is a very simple example of how to get at project files physical path on disk from a control designer

[code:c#]
    public class MyDesigner : ControlDesigner
    {
        public void DoSomethingWithProjectItemExample()
        {
            IWebApplication app = (IWebApplication)Component.Site.GetService(typeof(IWebApplication));
            IProjectItem item = app.GetProjectItemFromUrl("~/Default.aspx");
            string physicalPath = item.PhysicalPath;
            // do something with file
        }
    }
[/code]

 

Saturday, October 04, 2008 4:02:00 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -

Archive
<October 2008>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Ian Warwick
Sign In
Statistics
Total Posts: 33
This Year: 0
This Month: 0
This Week: 0
Comments: 4
Themes
Pick a theme:
All Content © 2012, Ian Warwick
DasBlog theme 'Business' created by Christoph De Baene (delarou)