i have two user controls
info.ascx and personal.ascx
i have a function like
in info.ascx i have a function like showdetails()
now i want to access this function from personal.ascx
can i do this ?
thanks in advance.
In a day when don't come across any problem -you can be sure that you are traveling in wrong path
you should better create a class where you will define the "functions" that you need in both files.
declare "static" the function and call it like nameofclass.nameoffunction
In a web project you can't reference a Page or User control class from a stand-alone class.
If you want to reference the User Control class, you need to create a web application project.
See the comparison of both project types - http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5
Assuming showdetails() is a public non-static method in info.ascx, you can only call it using an instance of the info.ascx User Control.
Therefore, in order to be able to call info.ascx's showdetails() in a response to an event in personal.ascx, you'd have to do it in the code behind of a page which contains instances of both of these User Controls. If you would like to do it consistently over several pages, I would recommend either you add an instance of info.ascx inside personal.ascx, or better yet build a 3rd User Control which contains both of them and place it in the relevant pages.
If any further clarifications are needed, please let me know.
Yes it is possible to call function of one ascx control from another.
Suppose u have one page in which u have dropped 2 ascx control.
1. a.ascx - Control Id in Page : a1 - Class Name : _a
2. b.ascx - Control Id in Page : b1 - Class Name : _b
Public Sub CallFromOutside()
Please mark as Answer if it helps u. Thanks!