Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

I have a bunch of functions that I want to use throughout my

ASP.NET project, and I want to put them in a module so the

entire project can use them.

 

This works fine with the code-behind pages, but if I want to call

one of these methods in the ASPX page itself (eg: <%

=GetNavBar() %>), the module is not in scope. The module and

the functions are both declared as Public.

 

Right now I have to put the methods in a class and declare a new

Public instance of the class in the code-behind page, which I can

then access from the ASPX code. This is a problem, however,

because I cannot access the Session variables directly, and a

new declaration of the class has to be put in every page.

 

Is there any way to declare the methods publicly so the ASPX

page can use them?

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

  • *Experts*
Posted

After reading divil's responses about evil modules in this thread, I

tried placing the methods in a class, declaring them as Public Shared.

Sure enough, when calling them from the page by using

<% =ProjectName.ClassName.MethodName() %>, everything

worked perfectly.

 

Thanks divil. :)

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

  • *Experts*
Posted

Yes, but since the class is declared in its own .vb file, I cannot

access Session variables without passing the Application or

Session class to the method.

 

Correct?

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...