Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I want to call event of Default.aspx.cs page from my class1.cs
help Me.
Thank u.
Posted
Comments
Varun Sareen 18-Feb-12 1:43am    
which event? and what is the requirement? please elaborate a little
Nilesh Patil Kolhapur 18-Feb-12 8:01am    
protected void btn_Click(object sender, EventArgs e)
{
response.write("hi");
}
i want to call this event from Class1.cs
bbirajdar 20-Feb-12 9:56am    
Whatever you are doing is a bad architecture... The classes are to be used for UI independent logic.
bbirajdar 20-Feb-12 9:57am    
Since you cannot access a Page object in a class and you are in any way NOT supposed to do it, you cannot do it..

1 solution

If it is during the postback of the page you are referring to you can do
C#
(Page)System.Web.HttpContext.Current.CurrentHandler


This will convert the current postback session into a Page which you can convert to the class that has your webpage and then call the function.

However, the comments are correct, this is bad architecture to do this. You really need to look at doing it a different way.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900