July 2006 - Posts

ASP.NET Podcast Show #60 - Atlas UpdatePanel - Video Special
Monday, July 31, 2006 4:35 PM

It seems Wally is revving up that podcast engine again. He mentioned a little while ago about doing video's to accompany the podcasts which I think is helpfull, especially in code intensive podcasts. Here is his first go at it. 

ASP.NET Podcast Url: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2006/07/31/363.aspx 

Launch in external player

Grab a copy of the PPT File.

Grab a copy of the Example Files.

Show Notes:

  • What is the Microsoft Atlas UpdatePanel?
  • Simple UpdatePanel.
  • Dynamically adding an UpdatePanel.
by Glav | 1 comment(s)
Filed under: , ,
ASP.NET Podcast Show #59 - Julie Lerman
Monday, July 31, 2006 4:00 PM

Subscribe – Everybody is doing it

ASP.NET Podcast url (for a direct download):
Show Notes:
  • Star Trek/2.0 on G4.  Has the world gone "2.0 Mad"?
  • Book industry
    • Java is down and .NET is up.
    • AJAX has gone from nowhere to somewhere.
  • Jason Gaylord interviews Julie Lerman
  • Databinding.
    • Datalist.  Some interesting things that I found.
    • Editable Gridview.  Does this look right or should I be doing something different.  Please send me your feedback.
by Glav | 1 comment(s)
Filed under: , ,
Overdue Podcast Post - ASP.NET Podcast Show #58 - John Papa
Friday, July 28, 2006 2:02 PM

So this post is long overdue. Been busy and sick lately and subsequently, missed posting this much earlier. Apologies to listeners and also to Wally.

http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2006/07/21/349.aspx

Subscribe.

Show Notes:

  • XML Feed Snafu.
  • Upcoming Community Events.
    • Portland.
    • Jacksonville.
    • Memphis.
    • Charleston.
    • Nashville.
  • Jay Karnik passed away.
  • Terri Morton.
  • Jason Alexander.
  • A new book tentatively titled “Beginning Atlas” has been approved.
    • Me, Glav, Scott Cate, Craig Shoemaker, Steve Smith, and Steve Orr will be the authors.
  • June CTP of Atlas.
  • John Papa.
  • How the heck does Adsense really work?
  • Screencasting.
by Glav | with no comments
Filed under: , , ,
Future Development - Next 10-20 years
Friday, July 21, 2006 2:58 PM

Did a post over on TechTalkBlogs today about what I think the future may look like for some application development (and thought it interesting enough to cross post to from here). No real surprises, and not real deep, but would be interested in others views.

http://techtalkblogs.com/blog/archive/2006/07/21/305.aspx

by Glav | with no comments
Filed under: , ,
Reflecting over the Page from an ASP.NET Server control at design time and some debugging pain
Tuesday, July 18, 2006 1:50 PM

I am working on an ASP.NET server control, and one of the properties of that control will typically contain a name of a boolean property that the Page exposes. At runtime this boolean property is called/examined and some action is taken as a result, however at design time, I wanted my ASP.NET control to be able to reflect over the page it is hosted on, and present a dropdown list of properties to select from, based on what the page has exposed.

Now this task is not so easy. After much pain and frustration, as well as a little help from a friend (thanks Mitch), I was able to get it working. Currently it still feels very hacky but here it is for anyone else who wants to do something similar.

INitially, I was hoping just to be able to get the page type, then use standard reflection to obtain that. Nothing I have found thus far enables me to do this *at design time*. All I ever get for a page type is "System.Web.UI.Page" and its standard set of properties.

What I did was to use the Visual Studio Environment API (which uses Interop) to get this job done. Have a look at the code below first, then I'll run through how I use it and what its doing.

public static string GetHostPagePath()
{
  string path = null;
  // Get an instance of the currently running Visual Studio IDE.
  EnvDTE80.DTE2 dte2;
  dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.8.0");
  if (dte2 != null)
  {
    foreach (EnvDTE.Property pr in dte2.ActiveDocument.ProjectItem.Properties)
    {
      if (string.Compare(pr.Name, "LocalPath", StringComparison.OrdinalIgnoreCase) == 0)
        path = pr.Value.ToString();
    }
  }
  return path;
}

So what this function does is simply return me the fully qualified path of the ASPX page that the server control has been placed on. Using that, I read in the contents of that file using the System.IO.File object and look for the "inherits" attribute of the “<%@ Page" directive. I grab out the class name from the inherits attribute and then create that type in code, from which I can reflect over the properties.

Oh yes, its hacky, but I haven't found a better way yet (would love some suggestions).

Now you'd think you can use the services that are accessible via the Container property component, something like this:

IDesignerHost svc = (IDesignerHost)myControl.Site.GetService(typeof(IDesignerHost));

and then access the svc.RootClassName property to get this, but this *only* gives the classname, no namespace prefix, that is, its not fully qualified, and so you can create a type from it and reflect over it. 

So that’s how I got to reflect over the page and grab all the public Boolean properties for use in my dropdown.

One more thing, when debugging a server control, you normally set that server control’s debug options to start an external program, and point that at the DEVENV.EXE visual studio executable so that when you start debugging, a new instance of VS.NET is launched and you can debug into your server control during design time.

The properties of the EnvDTE.DTE2 object during the debug experience reflected that of the initial VS.NET instance, that is, the one instance of VS.Net that starts the second instance of VS.NET which is actually the one you want to debug, NOT the initial instance. The net effect being you get to see properties of the EnvDTE.DTE2 object for the wrong instance of VS.NET, not the one where you are testing your server control. To get around this, I didn’t start new debugging instances, I simply did lots of System.Diagnostics.Trace.WriteLine statements to output debug information. Its longer and more painful, but at least you get to see the correct information. This little nuance can get quite confusing if you are not carefull.

 

 

by Glav | with no comments
Updating Component properties in the designer
Sunday, July 16, 2006 11:17 PM

I have been working on a set of custom ASP.NET controls that offer specific design time experience for a client. Part of that is to make some existing controls very designer friendly. Apart from some custom rendering, I have been adding SmartTag support to the control to enhance the design time experience. For those unaware, a good example of a SmartTag (or ActionList in coding terms) is shown below:

Smart Tag Example

So I wanted to add SmartTag support which showed some customised options for this particular control. The way you do this is via custom ActionLists.

When you create a component, you can attach a specific Designer to the component to customise the designer/design time experience of the component using a simple attribute on the component class like:

[Designer(typeof(CustomPanelDesigner))]
public class TestCustomPanel : Panel
{
  . . . . .

 

To attach a custom SmartTag menu, you need to define a custom ActionList within the custom designer class as shown in the following code:

public override System.ComponentModel.Design.DesignerActionItemCollection GetSortedActionItems()
{
  DesignerActionItemCollection coll =
new DesignerActionItemCollection();
  coll.Add(
new DesignerActionHeaderItem("Appearance"));
  coll.Add(
new DesignerActionPropertyItem("FormStyle", "Form CSS Style","Appearance"));
  return coll;
}

Now all this is well and good, and you can glean this from the documentation. What I found challenging was trying to update a property on the component being designed -AND- have that change reflected in the property window of the designer as well as persisted in the markup for the control within the page.

After much searching, and in the ed, reflecting over ASP.NEt controls, its this single statement which does the trick:

TypeDescriptor.GetProperties(this.relatedDesigner.Component)["YourPropertyToSet"].SetValue(this.relatedDesigner.Component, "your property new value");

Hopefully, thats usefull to somebody.

ASP.NET Podcast Show #57 - Wally on Interfaces
Tuesday, July 4, 2006 10:27 AM

Wally pumps out another podcast.

Subscribe.  You KNOW you want it.

 

Download.  Kinda like your father’s Oldsmobile.

 

URL: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2006/06/29/340.aspx

 

Show Notes:

namespace CallingInterface

{

      /// <summary>

      /// Summary description for Class1.

      /// </summary>

      public interface ICalling

      {

            bool GetConfig();

            bool Start();

            bool Stop();

            string Test();

            string ConfigFileLocation

            {

                  set;

                  get;

            }

      }

}

Dynamic Loading & Calling a mehod
      string strConfigFile;

      string strType = String.Empty;

      ArrayList aryListClassInfo;

      cLoader objLoad = new cLoader();

      AssemblyTypeClassInfo atci;

      strConfigFile = objLoad.GetConfigFile();

      Assembly assembly;

      aryListClassInfo = objLoad.LoadAssemblyInfoConfigFile(strConfigFile);

      aryListClassInfo = objLoad.LoadAssemblyInfoConfigFile(strConfigFile);

      foreach(Object obj in aryListClassInfo)

      {

            atci = (AssemblyTypeClassInfo)obj;

            assembly = Assembly.LoadFile(System.Windows.Forms.Application.StartupPath + @"\" + atci.AssemblyLocation);

            if (null != assembly)

            {

                  foreach(Type typDyn in assembly.GetTypes())

                  {

                        if ((typDyn.FullName == atci.ClassName) && (typDyn.IsClass == true))

                        {

                              try

                              {

                                    object objClass = Activator.CreateInstance(typDyn);

                                    if ( objClass is CallingInterface.ICalling  )

                                    {

                                          atci.TypeOfObject = typDyn;

                                          atci.objRef = objClass;

                                          typDyn.InvokeMember("ConfigFileLocation", BindingFlags.SetProperty | BindingFlags.Default, null, objClass, new Object[] {strConfigFile}); // Set a property

                                          object Result = typDyn.InvokeMember("GetConfig", BindingFlags.Default | BindingFlags.InvokeMethod, null, objClass, null);  // Call a method.

                                          Result = typDyn.InvokeMember("Start", BindingFlags.Default | BindingFlags.InvokeMethod, null, objClass, null);  // Call another method.

                                    }

                              }

                              catch(Exception exc)

                              {

                                    Console.WriteLine("Exception: " + exc.Message);

                              }

                              finally

                              {

                              }

                        }

                  }

            }

      }

by Glav | with no comments
Filed under: , ,
Guest Blogger at TechTalkBlogs
Tuesday, July 4, 2006 12:11 AM

I have been fortunate enough to be invited to be a guest blogger over at TechTalkBlogs. I have started the ball rolling and hopefully I can keep the momentum going that Rocky and Darren started.

Its pretty cool stuff and am overjoyed that Frank Arrigo asked me to be guest blogger.

My first post is here so hop on over and check it out.

by Glav | with no comments
Filed under: , , ,
More Posts

This Blog

Syndication