CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

MS SQL 2008 on ASP.NET Hosting
Free 3 Months



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 3/16/2004 9:18:24 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 134 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
MrCarl
Asp.Net User
Error BC30451: Name 'Session' is not declared.3/16/2004 9:18:24 AM

0/0

Hi,

Im trying to access a session variable in a user control but its not working :( Can anyone help?? I think I need another 'Import .....' bit but im not sure which one as ive tried everything I thought would make it work and nothing...

Here's the code:


Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Web
Imports System.Xml

Namespace Cienet

Public Class Security

Public Sub New()
End Sub

' Declare property variables
Private _intIdAgency as Integer
Private _intIdUsername as Integer
Private _intPagePermissionId as Integer

' Declare class variables
Private _strPermissions() as String
Private _strCmdReturn as String

Public WriteOnly Property AgencyId as Integer
Set (ByVal intIdAgency as Integer)
_intIdAgency = intIdAgency
End Set
End Property

Public WriteOnly Property UserId as Integer
Set (ByVal intIdUsername as Integer)
_intIdUsername = intIdUsername
End Set
End Property

Public WriteOnly Property PagePermissionId as Integer
Set (ByVal intPagePermissionId as Integer)
_intPagePermissionId = intPagePermissionId
End Set
End Property

Public Function SessionPermissionsCheck()

If Session("PermissionsString").ToString() = "" Then

Dim objSqlConnection as New SqlConnection(ConfigurationSettings.AppSettings("strCon"))

Dim objSqlCommand as New SqlCommand("spPagePermissions_Check", objSqlConnection)
objSqlCommand.CommandType = CommandType.StoredProcedure

objSqlCommand.Parameters.Add("@idAgency", SqlDbType.Int, 4).Value = _intIdAgency
objSqlCommand.Parameters.Add("@idUsername", SqlDbType.Int, 4).Value = _intIdUsername

objSqlConnection.Open()
_strCmdReturn = objSqlCommand.ExecuteScalar()
objSqlConnection.Close()

Session("PermissionsString") = _strCmdReturn

End If

_strPermissions = Session("PermissionsString").Split(",")

If Convert.ToInt32(_strPermissions(_intPagePermissionId)) = 1 Then
Return True
Else
Return False
End If

End Function

Public Function LivePermissionsCheck()

Dim objSqlConnection as New SqlConnection(ConfigurationSettings.AppSettings("strCon"))

Dim objSqlCommand as New SqlCommand("spPagePermissions_Check", objSqlConnection)
objSqlCommand.CommandType = CommandType.StoredProcedure

objSqlCommand.Parameters.Add("@idAgency", SqlDbType.Int, 4).Value = _intIdAgency
objSqlCommand.Parameters.Add("@idUsername", SqlDbType.Int, 4).Value = _intIdUsername

objSqlConnection.Open()
_strCmdReturn = objSqlCommand.ExecuteScalar()
objSqlConnection.Close()

_strPermissions = _strCmdReturn.Split(",")

If Convert.ToInt32(_strPermissions(_intPagePermissionId)) = 1 Then
Return True
Else
Return False
End If

End Function

End Class

End Namespace

bashar_naffa
Asp.Net User
Re: Error BC30451: Name 'Session' is not declared.3/16/2004 12:08:26 PM

0/0


First of all , You are trying to access a session object from a normal class !!!
you can just access the session or application or cache object from a class that inherited from UI.page or UI.UserControl. then the framework will make an instance from your class so session will be ready to use.

BUT u can use the code below to access the current context session


System.Web.HttpApplication CurApp = New System.Web.HttpApplication();
if (CurApp.Context.Current.Session("PermissionsString") == "1" ) { ...


u have to import System.Web Classes

Destiny is not a thing to be waited, it's a thing to be achieved
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Error BC30451: Name 'Session' is not declared. - ASP.NET Forums Error BC30451: Name 'Session' is not declared. Last post 03-16-2004 8:21 AM by bashar_naffa. 1 replies. Sort Posts: ...
BC30451: Name 'textfield2' is not declared. BC30451: Name 'textfield2' is not declared. what is the error. ... If not a session varaible, you can point the control source for the label ...
Name 'Config' is not declared. - ng.asp-net-forum.dotnetnuke ... Name 'Config' is not declared., > ROOT > NEWSGROUP > Asp.Net Forum ... Compiler Error Message: BC30451: Name 'Config' is not declared. ...
Name 'Session' not declared. - WebDeveloper.com error BC30451: Name 'Session' is not declared in a .vb file when trying to compile it into an assembly. Here is the line of code: ...
Error BC30451 with VBC : Name Application is not declared - ASP ... I try to compile a vb file with vbc and there are few errors like BC30451 : Name application is not declared. Problem appears for session ...
Compiler Error Message: BC30451: Name 'HelloMsg' is not declared. Mar 22, 2008 ... Compiler Error Message: BC30451: Name 'HelloMsg' is not declared. ... 'Please don't use SESSION to create the the HelloMsg ...
Compiler Error Message: BC30451: Name 'changelang' is not declared. as I rename the page to a .aspx file I get this error "Compiler Error Message: BC30451: Name 'changelang' is not declared.". I do not understand why I the ASP page works and the ... Display Session Variable in textbox? ...
"name not declared" but it is it says the name is not declared, but it is how can I fix this ? Compiler Error Message: BC30451: Name 'arrReportsList' is not declared. ======================= === ... Dim arrReportsList =split(Session("rpt"),",") ...
Microsoft: ASP.NET - BC30451 is not declared dataset error Compiler Error Message: BC30451: Name 'dsetSiteData1' is not declared. .... before the session is set if u try to get its value it will return empty value. ...
Compilation Error "The name Convert is not declared" F:\orespub\Encryption.vb(33) : error BC30451: Le nom 'Convert' n'est pas déclaré . Return Convert.ToBase64String(ms.GetBuffer(), 0, ms.Length) ... The name Convert is not declared. .... Response/Request/Session Objects ...




Search This Site:










single style declaration for multiple control instances

need a place to host a site.

composite control designer question

custom control - building a collection after databinding

how to add a caption on onmouseover on textbox control

question regarding hosting

web server control problem

enum property

hmc lab and "could not establish trust relationship with remote server" error

loadcontrolstate doesn't fire when control is placed in a masterpage placeholder

need some help on custom dropdownlist...

database deployment problems

custom control question, why can i not drag it onto my form?

calendar control

ie back button

persisting string array in html

using a div tag in a composite control

is downloading and installing samples of webcontrols valid ?

anyone is familiar with godaddy sql server?

composite control containing listbox, bgcolor problem

i lose the cheked checkbox in my controlewhen i refresh page

server purposing webcast dec 7th

assembly error with custom controls

cheap windows 2003 dedicated server ?

adding style to custom controls.

programmatically disable a buttons postback.

create a custom repeater control (with conditional templates)

how do i use viewstate in a server control?

urgent: composite control listbox viewstate problem

rich textbox control in webform

  Privacy | Contact Us
All Times Are GMT