Question

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?

Was it helpful?

Solution

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:

var editor1 = (AjaxControlToolkit.HTMLEditor.Editor)FindControl("Editor1");

and pass this as an extra parameter to the dd method:

public void dd(
    DropDownList DropDownList2,
    DropDownList DropDownList3,
    AjaxControlToolkit.HTMLEditor.Editor Editor1)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top