asp.net C# 中的错误
如何将 Editor1 作为参数传递:
在我的 aspx.cs 中,我调用同一项目的 .cs 文件中的函数,如下所示:
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDown abs = new DropDown();
abs.dd(this.DropDownList2, this.DropDownList3);
}
.CS 文件代码
public void dd(DropDownList DropDownList2, DropDownList DropDownList3)
{
//My code which contains DropDownList2 DropDownList3 and Editor1
}
我遇到的错误得到的是:
Error 1 The name 'Editor1' does not exist in the current context
我传递 DropDownList2 和 DropDownList3 的方式我无法传递 Editor1(它是一个 ajax 控件)。我该如何通过它?
How to pass Editor1 as Parameter:
In my aspx.cs i am giving a call to a function which is in .cs file for the same project, as follows:
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDown abs = new DropDown();
abs.dd(this.DropDownList2, this.DropDownList3);
}
.CS file code
public void dd(DropDownList DropDownList2, DropDownList DropDownList3)
{
//My code which contains DropDownList2 DropDownList3 and Editor1
}
The error that i am getting is:
Error 1 The name 'Editor1' does not exist in the current context
The way i have passed DropDownList2 and DropDownList3 i am not able to pass Editor1(It is an ajax control). How do i pass it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在过去的一段时间,在 ASP.NET 中,当我在 .aspx 中声明控件时,我确实经历过这样的事情,并且由于某种原因,它们无法在后面的代码中访问,在这种情况下,我只是重命名了这个坏页面,使用以下命令创建了新页面相同的代码,它有帮助。但是之后,当我切换到MVC时,我发现没有这种情况:)
看看文件“yourpageneme.aspx.designer.cs”是否没有您需要的控件名称,在您的情况下它称为“ Editor1”这意味着它在代码隐藏中不可用,因此您需要再次重新创建它,有时仅重新创建此控件不会有帮助,它仍然没有出现在“.aspx.designer.cs”中如果您需要重新创建页面。
In ASP.NET some time in the past i did experienced such things when i did declared controls in .aspx and for some reason they wasn't accessible in code behind, in such situations i just renamed this bad page, created new page with the same code, it helped. But after, when i am switched to MVC, i found that there is no such situations :)
Have a look in the file "yourpageneme.aspx.designer.cs" if there is no control name you need, in your case it called "Editor1" is it means it wont be available in code behind, so you need to recreate it once again, some times recreation just only of this control wont help, it is still not appearing in ".aspx.designer.cs" in in that cases you need to recreate the page.
如果出于某种原因,设计器没有为您的控件分配支持属性,您可以在事件处理程序中获取对它的引用:
并将其作为额外参数传递给 dd 方法:
If for whatever reason your control isn't being assigned a backing property by the designer, you can get a reference to it in your event handler thus:
and pass this as an extra parameter to the dd method: