how to call function in .aspx.cs from ascx.cs
i have function in .ascx.cs i want to use this function in page.aspx
thank u
Status:
Open Sep 04, 2008 - 04:53 AM
.net
8answers
Answers
Mar 26, 2009 - 03:54 AM
You can not access a function from usercontorl class unless you have instance of it in your page and the function is public. e.g. (usercontorl1.function1())
otherwise, you should have that function in a class inside AppCode
Apr 17, 2009 - 06:24 AM
The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.
The Quomon Team
Aug 12, 2009 - 02:15 AM
WebUserControl1.Test("a", "b");
here Test is the function on the ascx.cs page
and WebUserControl1 is the ascx page which is used in the aspx page
Oct 22, 2009 - 03:35 AM
I don't see any reason why you want to do this. But if you want you can use events and delegates.
Aug 10, 2010 - 06:59 AM
create that function "public" and then you can use that function like this
in ascx.cs
puplic void somefunction(arguments)
{
// your code here
}
in aspx.cs
controlObject.somefunction(arguments);
Apr 19, 2011 - 09:12 PM
WebUserControl1.Test("a", "b");
Jun 09, 2012 - 11:22 PM
Create separate class file and add your function in this class and refer this class in your both .aspx.cs and .ascx.cs page and use this common method anywhere you want.
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment