vb.net - Accessing a namespace declared in a page code behind from another page ASP.net -


i have page default.aspx in code behind file default.aspx.vb contains partial class , namespace called mynamesspace. default.aspx.vb file this

imports mynamespace  partial class default2     inherits system.web.ui.page  end class  namespace mynamespace     public class status         public id, score integer         public names string         public function checkscore() integer             return 1         end function     end class  end namespace 

but how can access same namespace in page code behind mypage.aspx? or not permitted?

absolutely can that. since code behind file nothing class, mypage.aspx code behind file can create instance of class , use it:-

dim cust new customer() dim result1 integer = cust.checkscore() 

but suggest create separate class instead of mixing code behind class.

or not permitted?

as have explained this, here can remember code behind file well. since class can have number of classes in code behind file either in same namspace or in namespace (as have created). question class acts code behind class? , answer in page directive of aspx page:-

<%@ page language="vb" autoeventwireup="true" codebehind="default2.aspx.vb"      inherits="mynamespace.default2" %> 

here codebehind attribute informs asp.net framework code behind file , inherits attribute informs actual class file associated aspx page.

i hope clear doubt.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -