Hi, I have a class called DDLImages.cs:
This is the code:
public class DDLImage
{
public string ddlImgPath;
public string ddlText;
public int ddlId;
public List<DDLImage> GetDDLImage()
{
List<DDLImage> lstDDLImage = new List<DDLImage>();
DDLImage objDDLImage;
return lstDDLImage;
}
}
and this an aspx file called ddlImages.aspx.cs:
This is the code behind file:
protected void Page_Load(object sender, EventArgs e)
{
Literal ltr = new Literal();
List<DDLImage> lstDDLImage = GetDDLImage();
for (int i = 0; i < lstDDLImage.Count; i++)
{
ltr.Text = ltr.Text + "<span class='ddlText' id='" + lstDDLImage[i].ddlId + "' onclick='GetSelectedValue(this);'>"
+ lstDDLImage[i].ddlImgPath + lstDDLImage[i].ddlText + "<s/span>" + "<br/>";
}
effect.Controls.Add(ltr);
}
Now I am getting an error that says the name GetDDLImage doesnot exists in the current context.
The error is raised from this line of code
List<DDLImage> lstDDLImage = GetDDLImage();
But when I call the GetDDLImage from the same file(aspx.cs) like this:
protected void Page_Load(object sender, EventArgs e)
{
Literal ltr = new Literal();
List<DDLImage> lstDDLImage = GetDDLImage();
for (int i = 0; i < lstDDLImage.Count; i++)
{
ltr.Text = ltr.Text + "<span class='ddlText' id='" + lstDDLImage[i].ddlId + "' onclick='GetSelectedValue(this);'>"
+ lstDDLImage[i].ddlImgPath + lstDDLImage[i].ddlText + "<s/span>" + "<br/>";
}
effect.Controls.Add(ltr);
}
public List<DDLImage> GetDDLImage()
{
List<DDLImage> lstDDLImage = new List<DDLImage>();
DDLImage objDDLImage;
return lstDDLImage;
}
It is working!!
now my kestion is why I can't access it directly from that class? instead of placing the GetDDLImage in the same file as aspx.cs file.
I want to access it directly!