原文在
http://dev.youkuaiyun.com/develop/article/26/26270.shtm
作者在引用用户控件时在后台的声明:
protected logInOutControl logInOutControl1;
网上也有很多文章这样写,但运行过程报错
编译器错误信息: CS0117: “ASP.WebForm1_aspx”并不包含对“LogInOutControl1”的定义
源错误:
行 263: #line default
行 264: #line hidden
行 265: this.LogInOutControl1 = __ctrl;
行 266:
行 267: #line 22 "C:/Inetpub/wwwroot/UserControl/WebForm1.aspx"
源文件: c:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/usercontrol/9fa4fc18/34e4d87/45alkeqe.0.cs 行: 265
--------------
写成这样到可以:
logInOutControl uc = this.FindControl("logInOutControl1") as logInOutControl;
uc.LogInOutClick +=new LogInOutClickHandler(LogInOutControl1_LogInOutClick);
作者在引用用户控件时在后台的声明:
protected logInOutControl logInOutControl1;
网上也有很多文章这样写,但运行过程报错
编译器错误信息: CS0117: “ASP.WebForm1_aspx”并不包含对“LogInOutControl1”的定义
源错误:
行 263: #line default
行 264: #line hidden
行 265: this.LogInOutControl1 = __ctrl;
行 266:
行 267: #line 22 "C:/Inetpub/wwwroot/UserControl/WebForm1.aspx"
源文件: c:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/usercontrol/9fa4fc18/34e4d87/45alkeqe.0.cs 行: 265
--------------
写成这样到可以:
logInOutControl uc = this.FindControl("logInOutControl1") as logInOutControl;
uc.LogInOutClick +=new LogInOutClickHandler(LogInOutControl1_LogInOutClick);
博客提及作者在引用用户控件时,后台声明运行报错,编译器提示“ASP.WebForm1_aspx”不包含对“LogInOutControl1”的定义。同时给出另一种可行写法,即使用FindControl方法并绑定事件。
1650

被折叠的 条评论
为什么被折叠?



