能否动态添加aspx源文件的代码? 如果只是实现你说的效果,我觉得可以用Visable来控制~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我不用TreeView写了一个树型菜单,但是不能对其中的项进行添加删除,所以能否通过某个事件来控制代码的删减,这是我想达到的要求。 不是很清楚你要问什么,不过你要实现的几个功能用Literal都可以实现。try it 自己举个例子:<form runat=server><asp:textbox id=txtb1 text=first runat=server/> <1><asp:textbox id=txtb2 text=second runat=server/> <2><asp:textbox id=txtb3 text=third runat=server/></form>如果要在<1>和<2>之间插入一个texbox,该如何通过一个按钮的事件来实现呢?动态地添加这段代码。 code as follows:[c# in .aspx]///<%@ Page Language="C#" %><script runat="server"> void Button1_Click(Object sender, EventArgs e) { TextBox myTextBox = new TextBox(); myTextBox.Text = "neo"; PlaceHolder1.Controls.Add(myTextBox); }</script><html><head></head><body> <form runat="server"> <asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder> <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button> </form></body></html> 可以在<1>与<2>之间加入一个PlaceHolder控件,然后这样写按钮的Click事件处理程序:<form runat=server><asp:textbox id=txtb1 text=first runat=server/> <1><asp:PlaceHolder id="holder" runat='server"/><asp:textbox id=txtb2 text=second runat=server/> <2><asp:textbox id=txtb3 text=third runat=server/></form>button_Click(object src,EventArgs e){TextBox box=new TextBox();box.Text="some text";holder.Controls.Add(box);} >>> 如果要在<1>和<2>之间插入一个texbox,该如何通过一个按钮的事件来实现呢?put following code:<asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>into <1> and <2>should appear as follows:...<asp:textbox id=txtb1 text=first runat=server/> <1> <asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder><asp:textbox id=txtb2 text=second runat=server/> <2>... 比如在一个asp:table控件中加一行并加入一个文本列一个图片列System.Web.UI.WebControls.TableRow tr;System.Web.UI.WebControls.TableCell tc;System.Web.UI.WebControls.Label lab;System.Web.UI.WebControls.Image img;tc=new System.Web.UI.WebControls.TableCell();tr=new System.Web.UI.WebControls.TableRow();lab=new System.Web.UI.WebControls.Label();lab.Text="Test";tc.Controls.Add(lab);tr.Cells.Add(tc);tc=new System.Web.UI.WebControls.TableCell();img=new System.Web.UI.WebControls.Image();img.ImageUrl="../Images/img.jpg";tc.Controls.Add(img);tr.Cells.Add(tc);this.Table1.Rows.Add(tr); CodeDom技术,可以自动生成源代码,可惜最近比较忙,一直没又时间深入研究。给你提个醒。 谁知道qq现在还开放接口吗? DropDownList全部选中 .NET读取数据库后,有几种输出的方式?最好与ASP比较着来 asp.Net Web应用程序部署到IIS上出错 税看样子还是定在3000上 写了个工资计算器 (2000的) 在字符串中,如何删除\ 请教各位:在一个ASPX页面中大多数元素都采用服务器控件会不会导致性能下降,增加服务器负担? .NET里网站打开的问题,急急急 如何解决Session老过期的问题? 水晶报表问题 web窗体浏览。急!急!急!在线等候。解决立刻给分!50 IE WebControls 哪里下载?
<form runat=server>
<asp:textbox id=txtb1 text=first runat=server/> <1>
<asp:textbox id=txtb2 text=second runat=server/> <2>
<asp:textbox id=txtb3 text=third runat=server/>
</form>如果要在<1>和<2>之间插入一个texbox,该如何通过一个按钮的事件来实现呢?
动态地添加这段代码。
[c# in .aspx]
///
<%@ Page Language="C#" %>
<script runat="server"> void Button1_Click(Object sender, EventArgs e)
{
TextBox myTextBox = new TextBox();
myTextBox.Text = "neo";
PlaceHolder1.Controls.Add(myTextBox);
}</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>
</form>
</body>
</html>
<asp:textbox id=txtb1 text=first runat=server/> <1>
<asp:PlaceHolder id="holder" runat='server"/>
<asp:textbox id=txtb2 text=second runat=server/> <2>
<asp:textbox id=txtb3 text=third runat=server/>
</form>
button_Click(object src,EventArgs e){
TextBox box=new TextBox();
box.Text="some text";
holder.Controls.Add(box);
}
put following code:
<asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>
into <1> and <2>should appear as follows:
...
<asp:textbox id=txtb1 text=first runat=server/> <1>
<asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:textbox id=txtb2 text=second runat=server/> <2>
...
并加入一个文本列一个图片列
System.Web.UI.WebControls.TableRow tr;
System.Web.UI.WebControls.TableCell tc;
System.Web.UI.WebControls.Label lab;
System.Web.UI.WebControls.Image img;tc=new System.Web.UI.WebControls.TableCell();
tr=new System.Web.UI.WebControls.TableRow();
lab=new System.Web.UI.WebControls.Label();
lab.Text="Test";
tc.Controls.Add(lab);
tr.Cells.Add(tc);
tc=new System.Web.UI.WebControls.TableCell();
img=new System.Web.UI.WebControls.Image();
img.ImageUrl="../Images/img.jpg";
tc.Controls.Add(img);
tr.Cells.Add(tc);
this.Table1.Rows.Add(tr);
给你提个醒。