Setting Global Variables Within Web Project On Login And Set Expiry Time

Dec 1, 2011

I'm developing a revised version of a system I have been using for years, but with all the advantages of .NET features that were not around when I first made this. It's proving a steep learning curve! So, when a user logs in through my Login.aspx page which simply compares username/password to Database record, the system creates a session variable containing the user's Username and various other things. There are two type of variable which will be common to all elements of this system
User Specific data, Username, Permissions, etc

Setting variables, drawn from a database of pre-set facilities which are setup within the system, some will determine which facilities work, how they work, and some will be dependent upon the User's permission. Obviously, I could set everything within the Session data, but that'd be inefficient wouldn't it? If I were to set these globally available variables in my App_Code, how would I go about setting this up so that, for example, those variables which require a database call, are set for the duration of the Logged-In session and do not require constant Database lookups? Further to that, those variables which are dependent on the session state, would need clearing on each LogOut. I am using VB.NET.


Sub Main In A Project-static And Global Variables

May 17, 2009

I try to create a sub main in a project but i can not.I have create a module called Module 1 and inside i have created a Main Sub which is intended to creta a thesaurus_form class instance , like this Code: Module module 1Public Sub Main()Dim thesaurus_form2= New Thesaurus_formEnd SubEnd module.Instead of this, once it has cretaed a first instance of the thesaurus_form class, it creates another one what i dont want at all..How can i do do make it execute the code which is inside the thesaurus_form_load sub..I also can not create a global variable or a staitc variable, because i receive this message.static is not valid in a member variable declaration.

View 2 Replies View Related

Define Some Global Variables Of A Class - Variables Occupy Memory?

Mar 23, 2012

I define some global variables of a class as follows:

Private Class MyClass
Private var1 as Decimal
Private list1 as List(Of string)[code].....

But I found that after this form is closed, all above variables, var1, list1, list2 still exist in memory. I thought they should be collected by gc since the form is already disposed as I confirmed.

Add: I have monitored half an hour after the form is closed. But these variables are not collected by gc. I have an automatic update procedure on the form which uses above variables.Since the above variables still hold values, the automatic update procedure is always called which causes exception. (One quick fix is to check if form.isDisposed in update procedure. But I do not think this is elegeant. Besides, these variables occupy memory.)

View 2 Replies View Related

Give Session Expiry Time (about 5 Min) In Program In Pageload Event?

Jan 4, 2010

How i can give session expiry time (about 5 min) in in pageload event

View 2 Replies View Related

Use Variables Or Properties, And Global Or Static Variables In A Class?

Jun 9, 2012

I'm new in .NET programming.I have a class Form1 that includes Button1_Click event.Button1_Click creates a multiple Text Boxies at run time)Here is the class:

Public Class Form1
Dim shiftDown As Integer
Dim counter As Integer


View 3 Replies View Related

Multithreading: Reading/setting Variables, And Passing Variables?

Mar 8, 2011

Question 1: What is the difference between "Background Worker" and "Worker Pool" as indicated within the MSDN samples provided.

Question 2: I noticed while using, AddressOf _Function_, variables cannot be passed; what would be an efficient solution to this?

Question 3: While using multithreading is it required to invoke before setting variables, or only form properties?

Question 4: While using System.Net.Sockets is it safe/efficient to use Application.DoEvents while waiting for new data; or would be using a Do While loop be fine without DoEvents since the action would be multithreaded? Note: there can be up to 2000-3000 sockets in use at a time.

View 10 Replies View Related

Setting Variables To Store User Setting For Applications

Feb 13, 2012

In our projects we use setting variables to store user setting for the applications. Moreover, with every latest version of the applications, we upgrade these variables to retain user settings.Normally, this works fine, but recently one of my end user reported an error i.e.Configuration System failed to initialize". The error is related to user.config file. Therefore we requested the user to send us his file.After received the folder, we noticed that it contains 3 files (3begfjb.newcfg,3begfjb.tmp¯ and user. config¯). 3begfjb.tmp¯ is an empty file, while 3begfjb.newcfg¯ and user.config¯ are identical files. We tried to open these files but the data in user.config isn't proper xml rather its unreadable formatted file.Do any you guys had experienced this sort of issue or any ideas how and what may have created these files and corrupted user.config file.

View 3 Replies View Related

.net - Creating Global Variables In Using C#?

Nov 25, 2009

I was working on window appication previously where i used to create global variables using modules in, but i found that in C# there is no concept of modules. so how can i create global vaiables in C#

View 9 Replies View Related

.net - Global Variables And DLL Files?

Nov 16, 2009

I want that global variables that sit in some DLL will be seen from other DLLs and EXE of that project.

I included in that VB file "Option Explicit On" as the first line .

But still no one can see my variables that were defined in that file . I made that all DLLs of that project depend to that one with the definition

I am using module and all my variables are public .

Option Explicit On
Module LPSoft_Core
#Region "Public"


View 1 Replies View Related

Declaring Global Variables In Vb?

Sep 29, 2011

The user clicks a button, a new form is generated where the user enters his/her password? How can I keep an in-memory copy of the username?

For instance in web forms, I can just use Session ("User"). How can I replicate this with winforms?

View 3 Replies View Related

Global Variables And Functions

Mar 24, 2010

how can i create global variables and functions within a visual basic project?

View 6 Replies View Related

How To Declare Global Variables

Aug 16, 2010

How I can declare global variables in that I can access them in all windows of my application?

View 5 Replies View Related

How To Handle Global Variables

Feb 2, 2009

I'm creating an App that requires a few global variables (user information mostly) and I wanted to know the best why to declare these. I would like to create a "global" class with properties for each variable, but the property values reset with every instance of the class. Plus, what is the must excepted way to declare globals, I've heard placing them in their own module is as Globals is not a good practice.

View 7 Replies View Related

Save All Global Variables?

Aug 20, 2009

I've got a RPG style game I am putting together - mostly to teach myself I am using alot of global variables to hold game values.[code]...

My question is -- I am trying to make a "SAVE" and "LOAD" the game's state. Is there a simple way to save the values of all my global variables, without having to type everysingle variable out. Is there anyway to call upon all my global variables at one time, and possible save/load them to a text file ?

View 3 Replies View Related

Using And Accessing Global Variables?

Apr 13, 2011

I want my "textbox.text" variable of my main form to be accessible by my other forms. Can somebody please guide me on making that a global variable?

View 12 Replies View Related

VS 2008 - Global Variables?

Apr 4, 2009

I have this little code here in vb 2008, I created a flag var to see if the user has clicked the button "enter" so the flag would be set to true. If its true then the game would begin...

I have a label that says "Press enter to Play", and if the user presses play the flag is true, the label visible is set to false. I have the keydown event to check if the enter button has been pressed, i checked if it works and it does, but the var of the flag is always false in my other subs...

Thats the thing with vb i dont understand is when you make a public variable, and when you change the value of the var in a sub, it doesnt change globally.


View 15 Replies View Related

Synchronize Time From The Global Time Server In C # Code

Aug 28, 2010

I am working on a windows application project on NIST time synchronization, but can't get a proper solution for it. If anyone can send me the code to synchronize time from the global time server in or C # code

View 2 Replies View Related

C# - Application Variables Global To Webgarden?

Jan 12, 2010

I am currently trying to program an online drawing program using the HTML5 canvas.the thing is, I need to have the current canvas saved somewhere globally. Static variables work, but they do not get shared across a Webgarden. This results in two different drawings being created.I will have to somehow create a new application object which is shared. I figured I will need an external application holding them.

1) How do I replace the application object with my own?
So either I will have to make my own program and call to it with remoting or use the ASP.NET session state server for application variables. I favor the Session State Server though.

2) How do I use the session state server for my own variables? How do I access it?

I searched high and low on the internet and only found the ideas mentioned above, but no help executing them.

I mainly code in VB.NET, but I can also understand C# code for examples.

A little info on my application:The client side has two canvas objects on top of each other. The top canvas object us used for drawing stuff, the canvas object below it holds the drawing in the end.When something is drawn, it is sent to the server in it's base64 representation. (getDataUri).The server puts this graphic on top of a stored Bitmap object through a Graphics object.

How the changes are being distributed to the other clients, I am working on that right now. Either I transfer the complete picture or each and every change that is submitted. This should work through Server Push. If this does not work thoroughly I will have to save and timestamp changes. A link to the current implementation, which is not currently fetching changes (but they get transfered to the server... With the problem that some reach one instance some reach the other on either w3wp in the webgarden) from the server is here: http:[url].....

View 1 Replies View Related

Calculator - Declaring Global Variables?

May 11, 2009

I need to write a simpe calc. program to add, mutiply, subtract and divide. I want to have two textboxes that I enter numbers in and when I click a button, +,-,/ or * a third text box will display the result.Rather than declaring my variables inside each instance of a click event I would like to declare them globally so I just need to perfom the calculation on them and display result. However declaring them globally doesn't work for me. I;ve tried the variables inside the btnAdd click event which works, but as I said I'd prefer to declare them onece globally.

Public Class Form1
Dim number1 As Double = CDbl(txtNum1.Text)
Dim number2 As Double = CDbl(txtNum2.Text)[code]...

View 1 Replies View Related

Declare Global Value Type Variables With New?

Dec 29, 2009

What happens if I do: Dim x As New Int32? Is a object of int placed on the heap? If it is, maybe your application would be able to access global variables faster if they were reference types.

A global variable as an value type should be somewhere at the bottom of the stack most of the time and it might take more time to get to this then to get a object from the heap. Unless it's the same story with the pointer of this object is also at the bottom of the stack of course.

View 9 Replies View Related

Displaying Images With Global Variables

Oct 29, 2009

I need to send up to to selected images (such as an apple) to pictureboxe's on a results page. at the moment I'm using global variables to attempt to display the images like this:
Me.pbItem1.Image = New Bitmap("images\" & gstItem1 & ".jpg")
Me.pbItem2.Image = New Bitmap("images\" & gstItem2 & ".jpg")
I get a directorynotfoundexception 'Could not find a part of the path '\images\apple.jpg' error. I'm new to VB and think this must have something to do with the default path or something.

View 4 Replies View Related

Making Variables In A Procedure Global?

Mar 15, 2012

I know the title seems pretty trivial but i have an issue and i can't seem to get round it, i have the following code within one sub procedure..

Dim X, Y As Integer
X = 32
Y = 285


View 2 Replies View Related

Tool To Identifying Global Variables?

Mar 30, 2011

Is there an automated tool for VB.Net that will identify all global variables in a project?Short of that, is there any scripts that can be used that will facilitate a manual review of global variables?There seems to be tools for C/C++, but not for VB.Net:Tools to find global/static variables in C codebases there a tool to list global variables used and output by a C function?

My current approach uses the following VS REGEX searches:
For finding global variables:


View 2 Replies View Related

Setting A Global Variable Making?

Aug 3, 2010

How do I optimize my code making it DRY approach. I want to make my variable to be on public/general so i can re-use it

Public Class BasicForm
Dim Product1, Product2, Product3, As Integer
Dim firstName, lastName As String


I want to move the variables (product1,product2) to somewhere else that I can set it one time and easily access it with other control. What I did before is I alway set the variables to every control.

View 1 Replies View Related

Declare Some Global Variables For Use In Various Subs/functions?

Oct 21, 2011

At the head of a module, I wish to declare some global variables for use in various subs/functions.

What is the difference between.Dim x as string and Private x as string / Public x as string, and when would I use one over the other?

View 1 Replies View Related

Global Variables For Data Exchange Between Forms

Sep 14, 2011

Is it a good practice using global variables in a VB (.NET) application in order to exchange data between forms? As global variable I mean a public variable defined in a module and not a public member or property of a class. Moreover as my personal rule I never access a global variable from a class, but I pass the values to the class via functions.


View 1 Replies View Related

Transferring Data Across Forms - Global Variables?

May 27, 2009

I have 2 forms in this application. One form is just a simple SQL statement that is generated into a grid. It displays columns/rows. From there I want to be able to click on a row and have the first column of that row transferred to another form. In the second form I want it inputted into a text box. So, the user doesn't have to copy the record back out of the form then open the other form and paste.

The form opening and closing is not the problem. The problem is getting the data to transfer from one form to another!! I am not sure how to do it.. I have only been coding in VB for a few days and no formal training. I am aware of global variables and would be willing to assign the data to a variable and then have it transferred into the textbox of a the second form.

I do not know how global variables work in VB. This is what I got so far............
'The user clicked the transfer button.
Dim obj As System.Data.DataRowView = grid.Current
MsgBox(obj.Item(0), vbInformation, "Selected Data")
[Code] .....

View 2 Replies View Related

VS 2005 Global Functions And Variables Within Solution?

Jun 23, 2009

I have a solution with 5 visual basic projects in it. Each project has an identical module with a few functions and constants - like handling our RS232 data, outputting events to log files, etc, etc..

If I want to change any of this common code, then I have to manually go through and change in each project. Is there a way to have a single module or class that's shared throughout the projects in the entire solution? I've considered creating and referencing a class library, but I'm likely to be making several little tweaks and changes to this "global code" and that method sounds like it could be just as awkward. Can I not just have a module that's visible to all projects, and compiled into each one seperately when the solution is built?

View 3 Replies View Related

VS 2008 Store Global Variables, In My.Settings Or My.Namespace?

Dec 4, 2009

Which is the best way to store global variables, in My.Settings or My.Namespace. The reason I ask is because I need to know certain boolean values if certain forms are open from other forms. At present I am defining Global Boolean variables in My.Application, which give the result I require.

View 3 Replies View Related

VS 2010 - Modules VERSUS Forms For Global Variables

Dec 19, 2010

I was a VB6 programmer. And back in the day global variables, functions and subroutines were put in a module. The program started in the module using a sub named Main(). Now in vb2010 it looks like using sub Main() is possible only for console apps, which is not what I want, I'm still trying to write a windows app but it looks like everything has to go at the top of the starting form?? How is this good coding practice? Shouldn't public vars and functions be in their own module?What is considered best practice?Are there any links that would walk me through the differences between vb6 and vb2010?

View 2 Replies View Related

Modify Time Span In Comparing More Than 40's Variables Time?

Mar 16, 2012

i have difficulties in making school schedule time and school bell? how to modify time span in comparing more than 40's variables time.

View 3 Replies View Related

Setting Variables In A Module?

Mar 7, 2011

I declare a variable as FRIEND in a Module.  Then I instantiate that variable in a Sub in the Module.  After the Sub runs, when I try to access that Variable, it is always NULL (Nothing).

Module MODULE_Main
Friend MyClass1 As Class1
Friend Sub Main()


How do I get MyClass1 to persist, meaning how do I get access to that variable outside of the Sub that instantiates it?

View 5 Replies View Related

Setting Private Variables From Datetimepicker?

Apr 3, 2010

I thought I had this figured out because it presented no errors, but when i tried to run it, I got this exception error:

Object reference not set to an instance of an object.

I am trying to set two private variables:

Private mdatStart As DateTime
Private mdatEnd As DateTime

I need to set these dates from a datetimepicker (dtpPickup, dtpReturn), but I don't now how to set it. I have tried using:

Private mdatStart As DateTime = New Date(dtpPickup.Value.Year, dtpPickup.Value.Month, dtpPickup.Value.Day)
'Private mdatEnd As DateTime = New DateTime(dtpReturn.Value.Year,


View 4 Replies View Related

Setting Variables To Use As File Names?

Sep 10, 2009

We have this current VBA program to help us with AutoCAD via the use of a template excel sheet.The setup we have created works well; however occasionally we have two drawings per folder, which often results in, two templates excel sheets of the same name, one overwriting the other. how I can set the active drawing name in a variable that our program uses to check for, then if not present that it creates a copy of out template and then saves it as the active drawings file name which was set as the variable

This would allow our program to locate the associated excel sheet by name then save it by the unique drawing name and prevent existing excel files being overwritten if in the same folder.

Option Explicit
Private Objexcel As Excel.Application
Private ObjWorkbook As Workbook


View 1 Replies View Related

VS 2008 Project / Application Global OleDbConnection Object

Jun 17, 2009

I need a single, global OleDbConnection. One which will be available to use throughout my app/project. Another project like a custom UserControl? I should mention I'm not using TableAdapters, BindingNavigitor, etc. The datasource is not associated with my project. I communicate with the Db through code I write. I'm just a hack trying to ride with the big dogs while I develop an app for my job... We were/are in the stone-age!!!

View 7 Replies View Related

Get The Difference Of Login Time And Logout Time?

Apr 10, 2012

How to get the difference of login time and logout time.(Eg. Login Time = login1 and Logout time = logout1).

what will be the format of the value.

View 4 Replies View Related

Quick Technique Of Setting / Saving Variables

Dec 26, 2011

I know this is a VB.Net messageboard, but it can work with in all languages. Is there a quick way to complete a line (sample code):
//Setting variables set 1
a = e;
b = f;
c = g;
d = h;

//Saving changes set 2
e = a;
f = b;
g = c;
h = d;
without having to type everything out...A technique using EXCEL or Notepad....Find and Replace. This would save a lot of time coding and becomes pain in the butt when you working with many variables.

View 4 Replies View Related

Use Variables For Setting 'From' Property In Net.Mail.MailMessage?

Oct 6, 2010

.From = New MailAddress("", "Big Mike")This does not;

Dim AddressFrom As String = ""
Dim FromDisplayName As String = "Big Mike"
.From = New MailAddress(AddressFrom , FromDisplayName)

I receive the error; The specified string is not in the form required for an e-mail address.I would REALLY like to use variables here so that I can read these two pieces of data from My.Settings. I've been searching for the answer for hours and I'm stumped.

View 3 Replies View Related

Declare Store And Access "global" Variables?

Jan 17, 2011

I have an application that I'm writing and I'm trying to declare two variables from my sql server, store the values and pass them to my forms.[code]...

View 5 Replies View Related

SQL Server - Storing And Retrieving Session Variables During Login

Feb 20, 2009

Is there a way to set session variables during login that are then available to reports? We have a reporting services server where we move and denormalize data from our transaction system for reporting purposes. In order to allow our users to login with the same user name and password from the transactional system we have set up custom forms authentication and after much trial and error it is finally working. In addition we have the authorization accessing our transactional system so that any changes in user authority is immediately reflected in Reporting Services.

Our problem now is that we would like to add some additional features such as locking down parameters depending on user authority/groups in our transactional system. We have found a way to do it but it's inefficient, basically we have stored procedures that will query our transactional system to check for access. The problem is that these queries will often be run for every report request even though the answer is unlikely to change. It would be nice to have access to session level data that can be set once during log in and then accessed from the reports.

View 3 Replies View Related

Copyrights 2005-15, All rights reserved