Demo Example documentation

When you install DeployWebLib it installs also solution with demo example in path $(MSBuildExtensionsPath)\DeployWebLib (e.g. c:\Program Files\MSBuild\DeployWebLib\Demo).

Solution consists of these:
  • Solution folder Keys with test snk file - test.snk
  • Project DeployWebLibUtils which contains one class Extensions with extension methods (there are other usefull methods, but i will describe only those which are required for current scenario)
    • extension method GetWebEmbeddControlType() on system type Type
      • gets the system Type for embedd user control, which will be later used to load user control into place holder
    • extension method GetWebEmbeddControlFullTypeName() on system type Type
      • gets the full assembly qualified name of system type for embedd user control, same as if you use GetWebEmbeddControlType().AssemblyQualifiedName
  • Project WebControlsLibrary
    • contains asp.net user controls which will be used within other web project WebApplicationTest
  • Project WebApplicationTest
    • contains Default.aspx file where is place holder to load user controls in
    • project has referenced to project reference WebControlsLibrary
      • this is needed because we want way to get strong type our user controls, and to use new extension method GetWebEmbeddControlType()
var embeddTypeOf = typeof(RegisterUser).GetWebEmbeddControlType();
  • project has also Post-build event which copies WebControlsLibrary.dll/pdb files (builded by DeployWebLib) from folder $(SolutionDir)\Modules\Debug info projects $(TargetDir) (BIN folder)
    • this is needed because project reference WebControlsLibrary points only to library without metadata of user controls
  • there are 3 buttons, OnClick button event loads custom user control from WebControlsLibrary library
var embeddTypeOf = typeof(RegisterUser).GetWebEmbeddControlType();
Control control = Page.LoadControl(embeddControlType, null);
this.ph.Controls.Add(control);
  • above code made this (code is little different to source file in demo (for demonstration purpose only)):
    • gets system type of embedd user control
    • loads user control from this embedd type
    • adds loaded control into controls collection in place holder

Last edited Nov 16, 2009 at 3:16 PM by terrorix, version 7

Comments

No comments yet.