Hi Localhost,
Thanks for your followup. As for the code snip on use Reflection api to
dynamically create controls , here is a simple Demo page I've made, its in
C# code , hope helps.
============aspx page==========================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>dynamiccontrols</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<asp:PlaceHolder id="phMain" runat="server"></asp:PlaceHolder></form>
</body>
</HTML>
==============code behind code====================
namespace FormAuthApp.reflection
{
/// <summary>
/// Summary description for dynamiccontrols.
/// </summary>
public class dynamiccontrols : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder phMain;
private void Page_Load(object sender, System.EventArgs e)
{
TextBox txt =
(TextBox)GetControlInstance("System.Web.UI.WebControls.TextBox","txtDynamic"
,"Dynamic TextBox");
if(txt != null)
{
phMain.Controls.Add(txt);
}
Button btn =
(Button)GetControlInstance("System.Web.UI.WebControls.Button","btnDynamic","
Dynamic Button");
if(btn != null)
{
phMain.Controls.Add(btn);
}
}
public object GetControlInstance(string type, string id, string text)
{
object ctrl = null;
try
{
Assembly asm =
Assembly.GetAssembly(typeof(System.Web.UI.WebControls.WebControl));
Type tp = asm.GetType(type,true,true);
ctrl = asm.CreateInstance(type,true);
tp.InvokeMember("ID",
BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetField |
BindingFlags.SetProperty | BindingFlags.IgnoreCase , null, ctrl, new
Object[]{id});
tp.InvokeMember("Text",
BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetField |
BindingFlags.SetProperty | BindingFlags.IgnoreCase , null, ctrl, new
Object[]{text});
}
catch(Exception ex)
{
Response.Write("<br>" + ex.Message);
}
return ctrl;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
====================================
Thanks.
Regards,
Steven Cheng
Microsoft Online Support

Signature
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Signature
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Steven Cheng[MSFT] - 30 Jun 2004 10:46 GMT
Hi Localhost,
Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If you have anything unclear or if
there're anything else we can help, please feel free to post here. Thanks.
Regards,
Steven Cheng
Microsoft Online Support

Signature
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Signature
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx