ext.net1.0 后台调用前台控件出错的问题
我想在cs后台文件中调用控件ID为button1,但是系统报错如下:错误 1 “_Default”不包含“Button1”的定义,并且找不到可接受类型...
我想在cs后台文件中调用控件ID为button1,但是系统报错如下:错误 1 “_Default”不包含“Button1”的定义,并且找不到可接受类型为“_Default”的第一个参数的扩展方法“Button1”(是否缺少 using 指令或程序集引用?) E:\测试1\Default.aspx.cs 33 14 E:\测试1\代码如下: protected void Button1_Click(object sender, DirectEventArgs e) { var win = new Window { ID = "Window1", Title = "My Window", Height = 185, Width = 350, Padding = 5, Html = "A new Window created at:" + DateTime.Now.ToLongTimeString() }; win.Listeners.Hide.Handler = "Button1.setDisabled(false);"; win.Render(this.Form); this.Button1.Disabled = true; }麻烦高手指点喽
展开
2个回答
展开全部
前台页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Panel runat="server" ID="p1"></asp:Panel>
</form>
</body>
</html>
后台页面
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default3 : System.Web.UI.Page
{
PlaceHolder myholder;
TextBox myt ;
protected void Page_Load(object sender, EventArgs e)
{
creatwebcontrol();
}
private void creatwebcontrol()
{
myholder = new PlaceHolder();
myt = new TextBox();
//myt.Height = 20;
//myt.Width = 200;
Button mybutton = new Button();
mybutton.Text = "获取内容";
mybutton.Click+=new EventHandler(mybutton_Click);
this.p1.Controls.Add(myt);
this.p1.Controls.Add(mybutton);
}
public void mybutton_Click(object sender, EventArgs e)
{
Response.Write(myt.Text);
}
}
如果有什么不懂的可以再问我
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Panel runat="server" ID="p1"></asp:Panel>
</form>
</body>
</html>
后台页面
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default3 : System.Web.UI.Page
{
PlaceHolder myholder;
TextBox myt ;
protected void Page_Load(object sender, EventArgs e)
{
creatwebcontrol();
}
private void creatwebcontrol()
{
myholder = new PlaceHolder();
myt = new TextBox();
//myt.Height = 20;
//myt.Width = 200;
Button mybutton = new Button();
mybutton.Text = "获取内容";
mybutton.Click+=new EventHandler(mybutton_Click);
this.p1.Controls.Add(myt);
this.p1.Controls.Add(mybutton);
}
public void mybutton_Click(object sender, EventArgs e)
{
Response.Write(myt.Text);
}
}
如果有什么不懂的可以再问我
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询