如何动态的在webpartzone中添加控件
解决方案 »
- 如果实现在线看电影,听音乐的功能.....
- 读取内容时如何只读取文字内容不调用里面的图片(用的是fckeditor编辑器)
- 怎样在浏览器下载文件时(这个下载是从FTP服务器下载),时候打开本机寻找存储路径.
- 如何在DataGrid/DataView数据绑定过程中插入行?
- 以前调用摸板生成HTML可以用的代码突然不能用,帮我看看,急!!!!
- 高分求:如何防止页面被拷贝了,只允许看,不给复制和保存。
- 如何实现:在弹出的模式窗口上,不输入正确的数据,不让关闭
- 菜鸟的问题:数据绑定的问题???
- 如何在后台 cs 中创建webform 而不是在aspx中写<asp:TextBox>...
- 我想在程序里面产生templateColunm,怎么写?
- 大家请进来指点一下
- ASP.NET中怎样把SqlDataReader的结果循环写入/传入Javascript的一个数组中?????? 在线等了一天了啊!!
///<summary>
/// 在指定的容器中的指定位置创建指定类型的控件。
/// </summary>
/// <param name="abs_control">要创建的控件的相关信息(结构体)</param>
/// <param name="ac_parentContainer">要在上面创建控件容器控件</param>
/// <param name="int ai_positionX">要创建的控件的X坐标</param>
/// <param name="int ai_positionY">要创建的控件的Y坐标</param>
/// <param name="as_msg">错误返回信息</param>
public int CreateControl(ButtonStruct abs_control, Control ac_parentContainer, int ai_positionX, int ai_positionY, out string as_msg)
{
as_msg = null;
try
{
string ls_assemblyQualifiedName = null;
if (ac_parentContainer is Form)
{
ls_assemblyQualifiedName = typeof(System.Windows.Forms.Form).AssemblyQualifiedName;
}
else if (ac_parentContainer is Panel)
{
ls_assemblyQualifiedName = typeof(System.Windows.Forms.Panel).AssemblyQualifiedName;
}
else
{
//as_msg = "暂不支持在" +typeof(ac_parentContainer).FullName.ToString() + "上面放置控件";
as_msg = "暂不支持在上面放置控件";
return -1;
}
string assemblyInformation = ls_assemblyQualifiedName.Substring(ls_assemblyQualifiedName.IndexOf(","));
Type lt_type = Type.GetType(abs_control.ls_type + assemblyInformation);
Control lc_newControl = (Control)System.Activator.CreateInstance(lt_type);
ac_parentContainer.SuspendLayout();
lc_newControl.Location = new System.Drawing.Point(ai_positionX, ai_positionY);
lc_newControl.Size = new System.Drawing.Size(abs_control.li_width, abs_control.li_height);
lc_newControl.Name = lt_type.Name + ac_parentContainer.Controls.Count.ToString();
lc_newControl.Text = abs_control.ls_text;
lc_newControl.Tag = abs_control.li_tag;
ac_parentContainer.Controls.Add(lc_newControl);
lc_newControl.Click += new EventHandler(NewControlClick);
ac_parentContainer.ResumeLayout();
}
catch (Exception ex)
{
as_msg = "创建控件失败,原因为:\n" + ex.Message.ToString();
return -1;
}
return 0;
}