Cassio
Junior Contributor
Hi!
C#: I have 2 projects in the solution. One contains a ASP.NET webform and the other contains a controler class. The controler project references the ASP.NET project, therefore the ASP.NET project cant reference the controler class.
How can I pass the webforms events to the controler class so it knows when a form event is fired?
Here's what did with no luck:
And in the controler class:
Now, obviously the contructor of the controler will never be called since its never instanciated. And I cant instanciate it cause the webform project isnt aware of the controler class.
How can I go around it?
Thanks!!!
C#: I have 2 projects in the solution. One contains a ASP.NET webform and the other contains a controler class. The controler project references the ASP.NET project, therefore the ASP.NET project cant reference the controler class.
How can I pass the webforms events to the controler class so it knows when a form event is fired?
Here's what did with no luck:
Code:
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
public delegate void FormLoad(object o, System.EventArgs e);
public event FormLoad onFormLoad;
public string texto
{
get
{
return TextBox1.Text;
}
set
{
TextBox1.Text = value;
}
}
private void Page_Load(object sender, System.EventArgs e)
{
onFormLoad(sender, e);
}
}
And in the controler class:
Code:
public class Controler
{
pagina.WebForm1 f = new pagina.WebForm1();
public Controler()
{
f.onFormLoad += new pagina.WebForm1.FormLoad(f_onFormLoad);
}
private void f_onFormLoad(object o, System.EventArgs e)
{
f.texto = "Great!!";
}
}
Now, obviously the contructor of the controler will never be called since its never instanciated. And I cant instanciate it cause the webform project isnt aware of the controler class.
How can I go around it?
Thanks!!!
Last edited: