Please help, going crasy! :(

  • Thread starter Thread starter Nemisis
  • Start date Start date
N

Nemisis

Hi everyone,

I am currently building my .Net website, everything was fine, until i
decided to put some generic functions into a module. The module is
located in App_Code, with 2 other of my Modules. but for some reason
everytime i try to call the function i get an error of "Name
'GeneralMethods' is not defined".

here is my module, as you can see very simple

Module GeneralMethods

' Function returns a Boolean, to determine if the string passed
in, is a valid Url
Public Function IsURL(ByVal pURL As String) As Boolean

Dim pattern As String = "http://([\/~_\.0-9A-Za-z#&-?]+)"
Dim RegEx As New System.Text.RegularExpressions.Regex(pattern,
System.Text.RegularExpressions.RegexOptions.Compiled)

If RegEx.IsMatch(pURL) Then
Return True
Else
Return False
End If

End Function

' Function returns a Boolean, to determine if the string passed
in, is a valid Email address
Public Function IsEmail(ByVal pEmail As String) As Boolean

Dim pattern As String = "[\w-]+@([\w-]+\.)+[\w-]+"
Dim RegEx As New System.Text.RegularExpressions.Regex(pattern,
System.Text.RegularExpressions.RegexOptions.Compiled)

If RegEx.IsMatch(pEmail) Then
Return True
Else
Return False
End If

End Function

End Module


And on the Asp.Net page, i am calling it as follows :

GeneralMethods.IsUrl(TextBox1.Text)


Can someone please help, i have tried putting the word "Public" in
front of Module, i have added the word "Shared" to all the functions
inside the module, still no difference. This module is nearly
identical to my other modules, which work perfect. Thanks in advanced
 
...
And on the Asp.Net page, i am calling it as follows :

GeneralMethods.IsUrl(TextBox1.Text)


Can someone please help, i have tried putting the word "Public" in
front of Module, i have added the word "Shared" to all the functions
inside the module, still no difference. This module is nearly
identical to my other modules, which work perfect. Thanks in advanced

Hmm, odd, I've not used "modules" myself, just typically classes, but the
one thing I have to do with those is instantiate them....

Thus...

GeneralMethods = New GeneralMethods

then you get to use it...

GeneralMethods.IsUrl(TextBox1.Text)

Not sure if this is the case with your problem, as I said I'm not so
familiar with modules...

HTH

Rob
 
No probs, i am running SP1. Does anyone else have the same problem if
they try it on theres?

Version 8.0.50727.762 (SP.050727-7600) - Is this the correct version?
Hopefully i havent updated with a Beta SP release lol?
 
Try using classes, not modules. If I am not mistaken in VB.NET a "Module" is
the equivalent of a static (Shared) class.
Peter
 
Back
Top