如何在其他页面中使用一页功能 [英] How To Use One page Function in Other Page

查看:97
本文介绍了如何在其他页面中使用一页功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-i在我的CS页面中创建了一个公共功能,我想在其他页面和global.asax中使用该功能,那么如何在其他页面中使用该功能?

解决方案

创建该类的对象,例如,如果您在page1中具有函数,则在page2中创建page1的对象,并使用该对象来调用obj.func()之类的函数.


<这里是一个例子:

 Class obj =  new  Class();
obj.methodCall(); 


为什么不创建一个通用类,将所有通用方法放在那儿.现在,您希望方法在哪个页面上创建类的对象并访问该方法.


-i create one public function in my cs page and i want to use that function in other page and global.asax so how to i use that function in other page?

解决方案

Create an object of that class, say if u have function in page1, in page2 create object of page1 and use that object to invoke your function like obj.func();


Here is an example:

Class obj = new Class();
obj.methodCall();


Why don''t you create a common class, having all methods common placed there. Now on which page you want the method create an object of the class and access the method.


这篇关于如何在其他页面中使用一页功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆