Hi
I want to load Form1.cs dynamically, and here is what I have
I have the following code in test.cs and Form1.cs in my solution.
using System;
using System.Data;
using System.Configuration;
using Gizmox.WebGUI.Common.Configuration;
using System.IO;
using System.Xml;
using Gizmox.WebGUI.Common.Interfaces;
using Gizmox.WebGUI.Forms;
using System.Reflection;
/// <summary>
/// Catalog module form router
/// </summary>
namespace LoginTest
{
[Serializable()]
public class CatalogModuleRouter : IFormFactory
{
#region ModuleForm class
/// <summary>
/// The actual form that will be displayed
/// </summary>
[Serializable()]
private class ModuleForm : Form
{
/// <summary>
/// The current hosted application
/// </summary>
//private IHostedApplication mobjCurrentHostedApplication = null;
/// <summary>
/// The current toolbar
/// </summary>
//private ToolBar mobjToolBar = null;
/// <summary>
/// Initializes a new instance of the <see cref="ModuleForm"/> class.
/// </summary>
/// <param name="objModule">The module control.</param>
public ModuleForm(Control objModuleControl)
{
// Add module contlrol
objModuleControl.Dock = DockStyle.Fill;
this.Controls.Add(objModuleControl);
// Create toolbar if is hosted application
//mobjCurrentHostedApplication = objModuleControl as IHostedApplication;
//if (mobjCurrentHostedApplication != null)
//{
// mobjToolBar = new ToolBar();
// mobjToolBar.Dock = DockStyle.Top;
// this.Controls.Add(mobjToolBar);
// CatalogSettings.InitializeCatalogModule(mobjCurrentHostedApplication, mobjToolBar, new EventHandler(ToolBarButton_Click));
//}
}
/// <summary>
/// Handles the Click event of the ToolBarButton control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
//private void ToolBarButton_Click(object sender, EventArgs e)
//{
// if (mobjCurrentHostedApplication != null)
// {
// CatalogSettings.HandleApplicationHostToolBarClick(mobjCurrentHostedApplication, this.mobjToolBar, (ToolBarButton)sender, e);
// }
//}
}
#endregion
#region IFormFactory Members
/// <summary>
/// Creates the application main form.
/// </summary>
/// <param name="strCurrentPage">The current page code.</param>
/// <param name="arrArguments">The application arguments.</param>
/// <returns>
/// A form object that will be the main form of the application.
/// </returns>
public IForm CreateForm(string strCurrentPage, params object[] arrArguments)
{
// Get the current context
IContext objContext = VWGContext.Current;
// The module to be dislayed
Type objModuleType = null;
// The module control to be displayed
Control objModuleControl = null;
// Check valid context and arguments
if (objContext != null && objContext.Arguments != null)
{
// Get module type
////string strModuleName = (string)objContext.Arguments["module"];
//if (strModuleName != null)
//{
// objModuleType = CatalogSettings.GetCatalogModuleTypeByModuleName(strModuleName);
//}
}
Assembly a = Assembly.GetExecutingAssembly();
Type t = a.GetType("Form1");
// Check for valid control
if (objModuleType == null)
{
objModuleType = typeof(UserControl);
}
// Create module control
objModuleControl = (Control)Activator.CreateInstance(objModuleType);
// Return a new module form
return new ModuleForm(objModuleControl);
}
#endregion
}
}
ANd in Web.config file
<Applications>
<Application Code="ModuleForm" Type="LoginTest.CatalogModuleRouter, LoginTest"/>
</Applications>
Project Property - Web Tab, I set "ModuleForm.wgx " as specific page,
Am i missing anything.
Please help.
Shan.