请教如何用编码添加控件? myButton.Location = new Point ( btnAdd.Location.X , locY ) ; http://www.yesky.com/SoftChannel/72342380468109312/20020114/213862_1.shtml 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 他会提示要放在runat="server"内的,代码我是直接放在private void Page_Load(object sender, System.EventArgs e)里写的 aspx文件<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm1" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:Panel id="Panel1" style="Z-INDEX: 101; LEFT: 320px; POSITION: absolute; TOP: 232px" runat="server" Width="240px" Height="120px">Panel</asp:Panel> </form> </body></HTML>aspx.cs文件using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace test{ /// <summary> /// WebForm1 的摘要说明。 /// </summary> public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.Panel Panel1; public TextBox TextBox1; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 TextBox1=new TextBox(); Panel1.Controls.Add(TextBox1); } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion }}就可以了,问人真是很难表达清楚啊 TextBox1=new TextBox();Controls.Add(TextBox1);TextBox1.Visable=true;TextBox1.Location=//自定义到自己想要的位置,问题一般会出现在这里。 TextBox1.Location=//自定义到自己想要的位置,问题一般会出现在这里。如何定义位置? TextBox1=new TextBox();Controls.Add(TextBox1);TextBox1.Visable=true;TextBox1.Location=//自定义到自己想要的位置,问题一般会出现在这里。补充一点 还要加一句话才行:TextBox1.BringToFront();加在一个按钮的点击事件中,点击按钮能出一个textbox1就对了 如何获得discuz论坛的搜索结果页面? dropdownlist 样式 未能找到元素“compiler”的架构信息。 我的Insert 语句错在哪里??? 欢迎大家来我的blog看看,指点指点,共同进步!有分哦 高手帮我调试一下。 请问 HTMLDocumentClass的execCommand执行的方法列表 大家快看看 谁会弄这个简单C#问题 谁深刻理解C#的反射和属性的含义和用法,能谈谈吗? 自定义控件,为什么不能在工具箱中拖入form中使用 请教一个简单的问题 请教DATAGRID问题?
private void Page_Load(object sender, System.EventArgs e)里写的
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Panel id="Panel1" style="Z-INDEX: 101; LEFT: 320px; POSITION: absolute; TOP: 232px" runat="server"
Width="240px" Height="120px">Panel</asp:Panel>
</form>
</body>
</HTML>
aspx.cs文件
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace test
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Panel Panel1;
public TextBox TextBox1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
TextBox1=new TextBox();
Panel1.Controls.Add(TextBox1); } #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}
就可以了,问人真是很难表达清楚啊
Controls.Add(TextBox1);
TextBox1.Visable=true;
TextBox1.Location=//自定义到自己想要的位置,问题一般会出现在这里。
如何定义位置?
Controls.Add(TextBox1);
TextBox1.Visable=true;
TextBox1.Location=//自定义到自己想要的位置,问题一般会出现在这里。补充一点 还要加一句话才行:TextBox1.BringToFront();加在一个按钮的点击事件中,点击按钮能出一个textbox1就对了