.NET 在IE中弹出一个自定义的WinForm窗体

public partial class _Default : System.Web.UI.Page
{
System.Windows.Forms.Form obj = null;
protected void Page_Load(object sender, EventArgs e)
{
obj= new System.Windows.Forms.Form();
}

/// <summary>
/// 点击按钮弹出窗体
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{

System.Windows.Forms.Label blb = new System.Windows.Forms.Label();
blb.Text = "这是一个Label";
obj.Controls.Add(blb);

System.Windows.Forms.TextBox objtxt = new System.Windows.Forms.TextBox();
objtxt.Text = "这是一个TextBox";
objtxt.Top = 50;
obj.Controls.Add(objtxt);

System.Windows.Forms.Button objbtn = new System.Windows.Forms.Button();
objbtn.Click += new EventHandler(objbtn_Click);
objbtn.Text = "点击事件";
objbtn.Top = 100;
obj.Controls.Add(objbtn);

obj.ShowDialog();
}

void objbtn_Click(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show("444444");
obj.Close();

}
}

posted @ 2019-09-20 16:55  yunfei3431  阅读(96)  评论(0)    收藏  举报