473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Calling Class from App_Code using vb

Hello,

I am converting a class in the App_Code folder from c# to vb and am having
problems calling the sub procedure. I have created a Sub called HidePanels
in the class "General". When I try to declare a new object of this type in
my codebehind, I get the error: "Type 'HidePanels' is not defined". Any
help with this would be appreciated. Thanks, sck10

code behind
===========
Protected Sub HidePanelAppCode()

Dim HidePanelsHelper As New HidePanels
HidePanelsHelper (Me.Page)

End Sub
App_Code Class
======================
Imports Microsoft.VisualBasic
Public Class General

Public Shared Sub HidePanels(ByVal MyPage As Page)
For Each MasterCtrl As Control In MyPage.Controls
If TypeOf MasterCtrl Is MasterPage Then
For Each FormCtrl As Control In MasterCtrl.Controls
If TypeOf FormCtrl Is HtmlForm Then
For Each ContentCtrl As Control In FormCtrl.Controls
If TypeOf ContentCtrl Is ContentPlaceHolder Then
For Each ChildCtrl As Control In ContentCtrl.Controls
If TypeOf ChildCtrl Is Panel Then
CType(ChildCtrl, Panel).Visible = False
End If
Next
End If
Next
End If
Next
End If
Next
End Sub

End Class
Aug 16 '06 #1
5 4012
Hi,

To access Shared (static in C#) function in VB.NET, use format such as
ClassName.SubName; so you need to use:

General.HidePanels(Me.Page)

#Shared Members in Visual Basic
http://msdn2.microsoft.com/en-us/library/4hbsxy95.aspx

Hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 17 '06 #2
Hi Walter,

I removed the "Shared" so that its now "Public Sub HidePanels(ByVal MyPage
As Page)". It's my understanding that I should be able to call this by
using the following in my codebehind:

Protected Sub ClosePanelAppCode()

' Create instance of the class.
Dim HidePanelsHelper As New HidePanels
HidePanels(Me.Page)

End Sub

However, I am still getting the error: Type 'HidePanels' is not defined.
Thanks, sck10...

App_Code Class
======================
Imports Microsoft.VisualBasic
Public Class General

Public Sub HidePanels(ByVal MyPage As Page)
For Each MasterCtrl As Control In MyPage.Controls
If TypeOf MasterCtrl Is MasterPage Then
For Each FormCtrl As Control In MasterCtrl.Controls
If TypeOf FormCtrl Is HtmlForm Then
For Each ContentCtrl As Control In FormCtrl.Controls
If TypeOf ContentCtrl Is ContentPlaceHolder Then
For Each ChildCtrl As Control In ContentCtrl.Controls
If TypeOf ChildCtrl Is Panel Then
CType(ChildCtrl, Panel).Visible = False
End If
Next
End If
Next
End If
Next
End If
Next
End Sub



"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:Nq**************@TK2MSFTNGXA01.phx.gbl...
Hi,

To access Shared (static in C#) function in VB.NET, use format such as
ClassName.SubName; so you need to use:

General.HidePanels(Me.Page)

#Shared Members in Visual Basic
http://msdn2.microsoft.com/en-us/library/4hbsxy95.aspx

Hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Aug 17 '06 #3
sck10 wrote:
Hi Walter,

I removed the "Shared" so that its now "Public Sub HidePanels(ByVal MyPage
As Page)". It's my understanding that I should be able to call this by
using the following in my codebehind:

Protected Sub ClosePanelAppCode()

' Create instance of the class.
Dim HidePanelsHelper As New HidePanels
HidePanels(Me.Page)

End Sub

However, I am still getting the error: Type 'HidePanels' is not defined.
Thanks, sck10...
Shouldn't
General.HidePanels(Me.Page)
be the method call?
>
App_Code Class
======================
Imports Microsoft.VisualBasic
Public Class General

Public Sub HidePanels(ByVal MyPage As Page)
For Each MasterCtrl As Control In MyPage.Controls
If TypeOf MasterCtrl Is MasterPage Then
For Each FormCtrl As Control In MasterCtrl.Controls
If TypeOf FormCtrl Is HtmlForm Then
For Each ContentCtrl As Control In FormCtrl.Controls
If TypeOf ContentCtrl Is ContentPlaceHolder Then
For Each ChildCtrl As Control In ContentCtrl.Controls
If TypeOf ChildCtrl Is Panel Then
CType(ChildCtrl, Panel).Visible = False
End If
Next
End If
Next
End If
Next
End If
Next
End Sub



"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:Nq**************@TK2MSFTNGXA01.phx.gbl...
>Hi,

To access Shared (static in C#) function in VB.NET, use format such as
ClassName.SubName; so you need to use:

General.HidePanels(Me.Page)

#Shared Members in Visual Basic
http://msdn2.microsoft.com/en-us/library/4hbsxy95.aspx

Hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Aug 17 '06 #4
Hi,

By removing the "Shared" keyword, it becomes an instance method. So you
need to use <instanceName>.MethodName to call it:

Dim HidePanelsHelper As New HidePanels
HidePanelsHelper.HidePanels(Me.Page)

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 18 '06 #5
Oops, sorry for the typo in previous reply, should be:

Dim HidePanelsHelper As New General
HidePanelsHelper.HidePanels(Me.Page)

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 18 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: alex | last post by:
Moving existing asp.net 1.1 app to 2.0 and using VS2005 I have noticed: 1) Class View window display ONLY name spaces and classes located in the new folder App_Code. 2) Using "Add New Item" on...
9
by: Leffe Andersson | last post by:
Hi folks! I have a MasterPage with some public methods, and I would like to call them from a (app_code) class. Is it possible to set a directive or an assembly reference to a MasterPage from a...
1
by: Shadow Lynx | last post by:
If this is not the most appropriate group for this question, please let me know. I noticed an odd priority difference in resolving names in VS 2005 (VWD Express) vs. the .NET 2.0 compiler (the...
4
by: sck10 | last post by:
Hello, I am trying to get the Month from the following using "switch" in my App_Code file. The error that I am getting is: An object reference is required for the nonstatic field, method, or...
2
by: sck10 | last post by:
Hello, How do you reference an array in the App_Code section? I tried using SystemColors, but got the error: 'System.Drawing.SystemColors' is a 'type' but is used like a 'variable'. Thanks,...
2
by: vinodkus | last post by:
I am unable to make a class file in asp.net in version2.0 . when i make a class file class1.cs it gives the message it should be in App folder. First of all u tell me what is app folder. but when i...
8
by: shapper | last post by:
Hello, I am working with VS 2008 and created a Web Application Project. I added a class but whatever I do the class is not visible to my aspx pages or anywhere else. I then changed the...
5
by: tshad | last post by:
I have the following class in my VS 2008 project that has a namespace of MyFunctions. ********************************* Imports System Imports System.Text.RegularExpressions Namespace...
2
by: Reggie | last post by:
Hi and TIA! I have a class file located in my root directory with all me web pages. I call/use the class and it works fine. I have no imports statements aspx or codebehind. My question is why? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.