Thursday, August 12, 2010

How to create page object using Markup file name of asp.net page

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    string markup = File.ReadAllText(Server.MapPath("~/Default.aspx"));
    Match match = Regex.Match(markup, "Inherits[ ]+=[ ]+"RegexOptions.IgnoreCase);
    if (match.Success) markup = markup.Replace(match.Value, "Inherits=");
    int l = markup.IndexOf("Inherits=\"") + 10;
    int u = markup.IndexOf("\"", l);
    string type = markup.Substring(l, u - l);
    string assemblyName = Assembly.GetExecutingAssembly().FullName;
    Page page = Activator.CreateInstance(Type.GetType(type)) as Page;
}

No comments:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...