0

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?

4
  • What is Editor1 and why do you want to pass it (what do you want to do with it)? Could you pass the 'value' of that control instead? Commented Jan 6, 2011 at 9:55
  • How are you creating Editor1? Commented Jan 6, 2011 at 9:56
  • Editor1 is a ajax control. asp.net/ajax/ajaxcontroltoolkit/Samples/HTMLEditor/… Commented Jan 6, 2011 at 10:01
  • @Hans Kesting i want to get some contents into it. Commented Jan 6, 2011 at 10:01

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.