CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




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: 102 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 ... Re: Error BC30451: Name 'Session' is not declared. ...
BC30451: Name 'Container' is not declared - Web Designers and ... Session("access") = sessionAccess. where login is a Dreamweaver DataSet. I get the following error:. BC30451: Name 'Container' is not declared. ...
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 ...
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: ...
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 ...
Error BC30451 with VBC : Name Application is not declared - ASP ... Error BC30451 with VBC : Name Application is not declared ... UserId As String) As Boolean Dim flag As Boolean = False If Session. ...
"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. ...
Visual Basic(Microsoft) -VB.NET/VB2005 - Compiler Error Message ... Compiler Error Message: BC30451 Name "variablename" is not declared. thread796- 1460881 ... BaCaseID = CInt(Session("CaseID")) Dim BaSardID As Int32 ...
BC30451: item not declared? : name, bc30451, declared Here is the error: BC30451: Name 'ClientOriginAreaID' is not declared. ... Session("StartPage")= Request.ServerVariables("SCRIPT_NAME") ...
Error BC30451 I am getting the error "BC30451: Name '__w' is not declared". ... best practices passing userid/pwd session variables from UI to Business ...




Search This Site:










addin opens vs 2005

migrating to asp.net 2.0

how do we code behind the "cancel" button?

setting up sharepoint services for web part development

cultureinfo

cannot load theme when try to call javascript in server side

applying style sheet styles to master page

has the form been submitted yet?

forum integration

asp.net templates

separate database for each portal?

validation question

some dnn user controls that are a bit of a mystery

cookie expiration

removing a module from the portal

bitmap images on forms...

moving .aspx pages to another project.

.aspx on a sharepoint team services website

when creating user - "access to path g:/www/app_data is denied"

need to play the audio file in asp.net page

problem accessing the msde database

can't login via portal alias; can login via portal name

trying to run fop.bat with some cmd line args - does nothing.

webparteditor -- and what vars to put in there, versus other db store.

master page and forms

wizard question

how can i clear module tables when module is deleted?

what does mvp stands for?

can someone please help me

changing default auto code generation language?

 
All Times Are GMT