Creating A Session Specific Global Variable?
May 12, 2012
Is it possible to create a variable that is global for each session in ASP.NET? Usually I do this with Session:
Session("my_variable") = 10
But this necessitates casting it every time I want to use it like so:
Dim my_variable as String = CInt(Session("my_variable"))
[code]......
View 2 Replies
ADVERTISEMENT
Mar 29, 2012
I have 2 web pages. In the first webpage I have a text box which takes an user input.The number of controls rendered in the second page is based on the user input in the first page.I am storing the user input from the first page as a session variable [code]Now, I wish to use this session variable in the next page for initializing a global variable and what I tried to do is Dim num_Invitees As Integer = CType (Session("NoOfControls ToGenerate"),Integer)But this gives me a NullReferenceException.Can someone please suggest me what exactly I should be doing in order to use the session variable to initialize a global variable and also why the session variable's value is null while using outside a function but works fine when used inside a function?
View 1 Replies
Sep 19, 2009
I have got a bit of code which creates an error when you start debugging. the code is:
Dim Gravitee As Decimal = TrackBar1.Value / 100
This code is a declaration (outside of a sub) so that it can be used in any subs I choose. I don't know why this causes an error?
View 3 Replies
Jul 15, 2010
What is Different between global variable and public variable?
View 1 Replies
Dec 23, 2009
I've got a problem losing session variables in an ASP/VB.NET application. The application allows searching for an item or it can show an item if provided with a unique link (in the browser). It holds information about the item in session variables. In the webpage showing an Item a user can click a button which opens a window with additional information about the item - obtained from a session variable. When I search for the item using the search engine and click the button - it works OK.
When I copy the link to a browser: the item is shown, however clicking the button returns a 'null exception' - the session variables with information about the item are lost. Moreover when I provide the link for the second time the button works, the variables are there!
View 1 Replies
Jan 14, 2011
Partial Class Preferences_MyPreferences
Inherits System.Web.UI.Page
Dim userID As String = Session("UserID")
This is just a page in asp.net. I want to be able to grab the Session("UserID") but every time I try, I get this error:
Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \ section in the application configuration.
If I put that Dim userID inside say the Page_Load Event, then it works fine. Why does it have to be inside an event? I want to dim it once, and use it throughout the page.
View 3 Replies
Jun 5, 2009
I have an aspx page with a button, the user clicks the button a session variable gets set, I then read the session variable later. here is an exaple of my button:
<
td style="width: 100px" align="center">
<asp:Button ID="btnCiv" runat="server" Height="32px" Width="50px" Font-Bold="true"
[code].....
Everybody seems to come up empty after the initial setting of data.
View 4 Replies
Jul 6, 2011
I programmed my website using visual basic code (via microsoft expression web) and need to post information to a remote location using a php page. How do I take variables from my visual basic code and transfer them to my php code? I was thinking sessions would work, but I haven't figured it out yet.
View 7 Replies
Mar 13, 2009
I like to create a session value that expires in 5 minutes.How to do that, do I need to manually compare creation time when I read it?
Session("sessionval") = myvariable
Session("sessioncreated") = now
View 7 Replies
Oct 10, 2011
My vb.net application needs to use a session variable. I don't really know how to use it in ASP.net. I've been trying to use what my books have, but I can't get this label to work. I need the user input to be validated against the database and if their code is in the database, the textbox should disappear and a label will appear saying Welcome. The way I wrote it, I get an error saying the server tag is not well formed and in the codebehind it says that the ID of my label is not declared. Can anyone spot any problems with the code I wrote?
[Code]....
View 3 Replies
Feb 3, 2011
I am using ASP.NET. It is possible to create a session variable on page load just for a particular page/url? The problem that I have is: The user comes to page 1 and the session variable becomes A, then he opens page 2 in a new tab and the session variable because B on both page 1 and page 2. So when the user needs the session variable on page 1 it does not work because the variable have changed!
View 2 Replies
Feb 14, 2011
Sub Authenticate()
Dim username As String
Dim password As String
[code].....
View 4 Replies
Jun 2, 2009
I'm using a compiled .dll provided by someone else -- I know little about it, other than it has a session variable that I must access in a way that is strange to me. Not sure what to call it -- have googled for words that I thought might be right, but so far no success.
View 2 Replies
Jan 23, 2012
I was guided by Nuux who was kind enough to help me through the intricate process of localizing my website, and then giving the client the option to manually select their own language by clicking a flag and it lasts for their entire time/session they're on the website. My website is Visual Studio 2010 / vb / net 4.0.
In doing so, I created a class, BasePage.vb. ALL of my pages are set to inherit: BasePage in their code behind. Here's a line of interest from BasePage.vb:
'retrieve culture information from session
Dim culture__1 As String = Convert.ToString(Session([Global].SESSION_KEY_CULTURE))
Everything functions great, and Nuux was a perfect help. I have 1 remaining issue. When I go to my homepage (or any page), there's a strange query string in there. I think it's that line in BasePage.vb, more than something on a page's code behind, because it happens even if I open a browser, bypass the homepage by going directly to mydomain/about.aspx. For instance, just go to the about page and this shows up: mydomain.com/(S(tp5bafoygn0ahwdp1mh0x4v5))/about.aspx
But the languages work great and last the entire session! What is the (S(tp5bafoygn0ahwdp1mh0x4v5)) ? Should I get rid of it, and if so, how would I go about doing this?
View 1 Replies
Nov 25, 2009
I was working on window appication previously where i used to create global variables using modules in vb.net, but i found that in C# there is no concept of modules. so how can i create global vaiables in C#
View 9 Replies
Sep 4, 2009
Im creating a desktop app with multiple forms. My ideal aim is to create 1 MenuStrip to use throughout the different forms (the same MenuStrip) appears on the different forms. otherwise I'll be copying the MenuStrips from 1 form to another and copying the Event code. What is the best way of doing this? I've created UserControl, put my MenuStrip on it along with me Code, then I load an instance of it whenever a new form loads. This seems to work fine until I want close the Main Form. I've tried ' Me.Hide ' but that just hides the UserControl. So the MenuStrip appears on Form A, when i click a Menu Item I want it to close Form A and open Form B.
View 2 Replies
Sep 4, 2009
Im creating a desktop app with multiple forms. My ideal aim is to create 1 MenuStrip to use throughout the different forms (the same MenuStrip) appears on the different forms. otherwise I'll be copying the MenuStrips from 1 form to another and copying the Event code
I've created UserControl, put my MenuStrip on it along with me Code, then I load an instance of it whenever a new form loads. This seems to work fine until I want close the Main Form. I've tried ' Me.Hide ' but that just hides the UserControl
So the MenuStrip appears on Form A, when i click a Menu Item I want it to close Form A and open Form B
View 2 Replies
Mar 3, 2009
Here is the situation: User logs in via username/password stored in an MSSQL database If the user is authenticated, the system makes a session variable with username/SHA1'd password and boolean if the user is logged in or not (for subsequent pages) I need to be able to destroy the session variable. I want a confirmation box as well.
This is what I have so far:
<script type="text/javascript">
//<![CDATA[
function doLogout() {
[CODE]...
Since it is an ajax request won't reload the page (the functionality works fine, the request destroys the session), I think I need a different approach to do this. I would really like to be able to do it all in ASP.NET if possible.
View 1 Replies
May 24, 2012
Does session variable shared accross different browser? If not is there away that I can share information accross browser similar to the functionality of caching but the scope is wider.
View 3 Replies
May 7, 2009
I keep a Session variable when the user is logged in. So that when the user click on btnLogout it must clear all my sessions and Log the User out for GOOD!!!
It does clear my sessions but if i click the BACK button in IE right after i logged out then i am still logged in! Meaning it goes back to screen where the user was still logged into.
My code on log out
protected void btnLogout_Click
{
Session.Clear();
Session.Abandon();
[Code]....
Is there maybe an option in code i can do that will disable the user from pressing the BACK button in the Web Browzer?
View 4 Replies
Sep 18, 2011
Im trying to grasp session varibles, i understand what they are etc but i would like to know how to define a type for each session variable.Iv written it like this
Session("Title") = txtTitleContent.Text
How can i tell it what type of value is going to be in it, because at the moment im only playing about with strings, but what if i have an integer and want to pass it back to the back end to save it will throw an error saying "conversion from string to integer is not valid" should i use Cint to deal with this?
View 1 Replies
Feb 27, 2009
As the title states, I have a session variable that is set during a login script with asp.net and vb.net code-behind. Can I call a javascript function when a link is clicked that will destroy that session variable? If it is possible, can I use jQuery to make that process easier?
View 4 Replies
Aug 8, 2011
I am using VWD 2008 express edition to edit the code below. The HTML Insert Code is as follows: I have no code behind.
<Fields>
Line
24 <asp:TemplateField
HeaderText="RecordID"
SortExpression="RecordID">
[Code] .....
My objective is to populate the DetailsView with a single field in ASP.Net VB, when Inserted, a Record will be created with only a key field.
View 21 Replies
Feb 24, 2012
I have a master page with the following vb code in the code file...
Public Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
If Not IsPostBack Then
If Session("key") Is Nothing Then
[code]......
View 3 Replies
Jun 30, 2011
I'm using some session variables to store and pass data across several pages of an ASP.Net application. The behavior is a bit unpredictable though. [Code] Ok so far so good, on a normal page load. If the user completes the form action, hits the next page, and decides OH NO, i needed to change field xyz, and clicks back, corrects the data, then submits, the session variable is showing as NULL. Why would a cached session behave this way? I'm not destroying/clearing the variable, unless I fail to understand the scope of session variables.
View 1 Replies
Sep 29, 2011
I have a session variable in my asp.net application. The session variable holds a value from the database, that reflects a customized HTML color value.In my application, I have an asp button with server side code
btnContinue.BackColor = System.Drawing.Color.FromName(Session("ContinueColor"))
Issue: However, when I run the application, the color value is not being reflected in the button. I did double check, and the session variable does hold the correct value.There are other objects, that use session variables to display colors, and they are working fine.
Update: When I force a color "btnContinue.BackColor = Drawing.Color.Blue", that works perfectly fine.
View 2 Replies
Dec 22, 2011
I have a variable whose scope needs to be global, because it needs to be called in a function as well as in a button press. So I declared the variable in a Module so it would be global.The problem is that the value of this variable needs to be equal to the value of the text property of a textbox in the form.You enter a string into the textbox, in this case I entered "Hello". Then you click the button and it displays what you wrote.You click OK in that message box and change the value in the textbox. In this case I changed it to "Goodbye". Then I hit the button again, but the variable did not change values and the messagebox displays "Hello" again.
[code]....
Here is the entire source code:
Module Module1
Public strDataValue = frmTest.txtDataValue.Text
End Module
[code]....
Note: This is just a demonstration of a problem I'm having in a much larger program so the variable does have to be global.
View 4 Replies
Sep 21, 2011
If we declare a global variable in module in vb.net, we can use that variable in anywhere in project.
How can we achieve same thing in C#.
Previously when we tried to convert a vb.net project to C#, we succeeded in removing the syntax error but we can't access global variable in a form.
I need some solution or guidance. Where I am making a mistake?
View 7 Replies
Feb 6, 2010
VB2008: I would like to set a #Const value in a module and use it throughout my project. Is this possible? It appears that the #Const scope is limited to the function it's in.
View 5 Replies
Oct 11, 2010
How Can I create a Global Varibale for my vb.net project. When I LongIn I want to keep the user Id in a varible and I will Use it in deferent Forms. And The User name will be saver in the varible untill I close the Software.
View 1 Replies