State Management :: Losing A Value Assigned To A Variable?

Dec 28, 2010

I'm fairly new to ASP.net development as may have been noticed by some of my other posts and so here goes another one.I have a web page in which I allow users to enter data that will be used to populate a database and then graph data based on the information that was saved in the database. I have 10 sets of criteria that the user can enter and as they enter values for each individual set, I make sure all the parameters are filled in and set a variable called blnParm1, blnParm2, blnParm3, etc. Anyway, as each DropDownList box fires off an event the values of my blnParm variables is reset because each time the event is fired the page is PostBack therefore my variables are redeclared. I know the page is being PostBack because each of the DropDownList boxes have AutoPostBack set to true. I had to do this so that I could get the OnSelectedIndexChanged event to fire for each of the DropDownList boxes. So, how do I preserve my variables through this PostBack or how do I get the events to trigger without calling AutoPostBack?

Some more info, my variables are declared globally in my aspx.cs file as private bool. The code is working like it should as far as populating drop downs dynamically based on other data input by the user, the controls all have their values preserved as the page is PostBack.

View 2 Replies


Similar Messages:

State Management :: Losing Session State In Global.asax File?

Feb 2, 2011

I am trying to set a session variable in the global.asax file and keep running into the problem that the Session is null.

I am running my application in VS2008 and using asp.net 3.51.

Here is my code:

1. In my web.config file I have enabled the session state and added the following line;

<sessionState
cookieless="false"
mode="InProc"
timeout="60"
></sessionState>

2. In the Session_Start procedure in the Global.asax file I set the session variable to a default value.

[Code]....

My problem seems to be that when the Application_Error procedure is executed the session state is lost.

Does anyone know why the session state isn't available in the Global.asax file.

View 9 Replies

State Management :: Losing View State Upon Refresh?

May 13, 2010

I have two radio button list:

*1* report views -- 4 options -- NOT in updatepanel
*2* pagination views -- 2 options -- IS in updatepanel

The situation goes as follows: Refresh WORKS in default setting but when I select *2* radio button options and refresh the page renders the state that the (1) was entered in.

Example: () are the radio buttons
Report Viewing: () (x) () () Pagination View: (x) () REFRESH works!
Report Viewing: () (x) () () Pagination View: () (x) REFRESH fails to display Report Viewing: () (x) () () Pagination View: (x) ()
Report Viewing: () (x) () () Pagination View: (x) () REFRESH works!
OR: () are the radio buttons
Report Viewing: () () (x) () Pagination View: () (x) REFRESH works
Report Viewing: () () (x) () Pagination View: (x) () REFRESH fails to display Report Viewing: () (x) () () Pagination View: () (x)
Report Viewing: () () (x) () Pagination View: () (x) REFRESH works

I am using the session variable to hold the Pagination Viewing option but during page states, I've noticed that when a 2nd option is selected of *2* radio buttons (doesn't matter of 1st or 2nd option was initially selected) that during debugging mode the step over corrects the issue but not the right table viewing. Upon entering Page_Init selection selection index of radio button list returns to 1st option.

View 4 Replies

State Management :: Losing Data Between Postback?

Mar 27, 2010

I am in beginner level on developing web pages. I was coding on desktop applications and as you know it is easy to say that web applications are extremely different than desktop applications.

I wonder why data are lost between postbacks.???? And what is the best way not to lose the data belonging to a specific control (especially gridview). Session or viewstate or anything else?

View 10 Replies

State Management :: Literal Losing Value On PostBack?

Dec 13, 2010

Never had this happen before. I just upgraded my site from 3.5 to 4.0. Here's the scenario:

1.) I have a literal on a web form, in an UpdatePanel.

2.) On PostBack, the Literal's "Text" property loses it's value. The ViewState is enabled throughout the page. Further, I changed the Literal to a label and it also has this problem. The TextBox's appear to keep their values.

3.) If I remove all of the Ajax controls (which currently is just the UpdatePanel and the ScriptManager) then the Literal control keeps it's value through PostBacks.

4.) There is no client side JavaScript where I'm manually changing the values of these controls. They are only editted in the server side events.

I have read that setting the AutomaticDataBind property in the web.config could remedy this but I can't find any documentation on it and I don't know where to put it in the web.config to even try it.

View 7 Replies

State Management :: Large Session Object Losing Value?

May 10, 2010

I have a asp.net application where I am saving off into session the user privilege information. From a grid I am bring up a new window by using the window.open. It seems that it is whiping out the values in session. A temporary bandaid I have placed on it is to recall the database if the value is nothing to reset the user object. I have found all over the internet that this is an issue with the window.open in IE 7 and IE 8. Has anyone else run into this and able to actually fix it?

View 4 Replies

State Management :: Certain Users Losing Certain Session Variables?

Mar 14, 2011

There are a couple of user's experiences session variable loss after they've clicked a confirm button and their information is email via a relay hosting server. Below, I commented exactly where the session variables get lost.

What could be causing the session variable loss? So far, this only happens to a few users.

Part of the email that gets sent out:

[Code]....

Web config file:

[Code]....

View 4 Replies

State Management :: Losing Session Data With Response.Redirect?

Oct 25, 2010

This is weird. In my newly developed chat application, when I invoke Response.Redirect, I am losing my session data. What is particualrly odd is that this sometimes seems to occur after a slight delay, so I reach the page, and then the session info gets lost momentarily thereafter. Mostly though it seems to get lost immediately. I have of course googled this issue, but yet to find anything that speaks to my problem. SessionState is in InProc mode. Session state has been working fine for me until this unexpected problem, so everything is configured right. So far the only workaround I can think of is to use a link instead of a button, and use javascript to call a server-side function on onclick to do the work I need to do before the link gets invoked. Messy, and I'd rather not go that way unless there's no alternative.

Just to preempt one red herring, I do use Response.Redirect(<address>, false).

The problem occurs both on the testing and production servers. I'm running ASP.NET 3.5 on IIS7.

View 1 Replies

State Management :: Public Variable Vs Session Variable To Store Logged In UserID

May 17, 2010

I have a web application which uses a session variable to store the logged in userid. If no user is logged in, of course this variable will be empty and the contents displayed on my website are meant for guests. If there is a user logged in, the user specific controls/access/links will then be a displayed.

I am now having issues with my hosting where on shared application pool, the worker recycle is triggered every 90 minutes, this will clear sessions causing all my users to be logged out. I opted for a dedicated application pool, which got worse because I am only allocated 50MB memory limit and if this is reached, the worker recycle is triggered and I lose my sessions again. I have tried as much as possible optimization techniques, e.g. dispose where possible, close connections, disable viewstate for static controls etc but my memory per instance keeps building up from page to page without any signs of improvement. I don't use loops nor store huge objects like bitmaps etc but my sessions are now gone even faster than 90 minutes in shared application pool before.

I have considered using SQL Session State but there isn't a simple guide on using this with MySQL. I am getting desperate and considering using a public variable, a string as a replacement to store logged in user id instead of in a session variable. I am pretty sure this will solve my issue with sessions being recycled but are there any negative consequences of doing this? One problem I can think of is if the user closes the browser, the system will never know that the user is now logged out and this public variable should be nothing. In this scenario, will the GC eventually clear this abandoned public variable.

View 10 Replies

State Management :: Session Variable Authentication State Timeout?

Dec 3, 2010

I am building a web app that is limited to one database, therefore I cannot use the ASP.NET config tool. As a quick means of getting this app online, I tried to use a simple session variable. The login page verifies the user's credentials, and if they pass, it sets the session variable to a certain value. All other pages check in the page_load event whether or not the session variable is equal to that value. The problem is that once being logged in for a short while and sending and recieving some data, the session variable resets, and I'm returned to the login page to repeat the process. Here's the basic code from my webforms:

[code]....

Is there some setting I need to change in the web.config file to adjust the cookie timeout or is that only for the config tool authentication methods?

View 5 Replies

Public Variable C# - Variable Is Assigned A Value In Another Class?

Mar 7, 2010

[Code]....

The variable is assigned a value in another class like this:

[Code]....

View 1 Replies

State Management :: Int Variable Value Not Getting The Stored Value

Mar 17, 2011

I have define a variable called number of type int just after the the class definition as follows.

[Code]....

I store a value from a sql query result in the Number variable. ( eg: lets say 23). This gets assigned correctly to theNumber variable. ( checked using a break point)

Then the user does some updates to the web page ( data entry). The web page includes post back events also.

Finally I need to update the webpage in the database. When I do this I see the Number variable has change to 0. ( and not the 23 as in our example). Its always 0 at the time when I update.

I do not do anything for the number variable in the code.

View 5 Replies

State Management :: Session Variable In Mshtml?

Jan 18, 2011

i want to use seession like variable in mshtml.

View 1 Replies

State Management :: Passing The Variable To Another Page?

May 3, 2010

want to use the value of a variable on to the other page, what i am supposed to do for that.i am novice at asp.net

View 8 Replies

State Management :: Get A List Of Session Variable?

Jun 16, 2010

Each time a session starts, I save

Session("UserName")= xyz$

My question is:

what would be the vb code to get a list of all "UserName" 's

(session alive at this moment) ?

View 7 Replies

State Management :: Access Session Variable?

Jul 18, 2010

I have two projects ,one is webforms and other is Business logic, i am storing username in Session Variable, i have audit module in businss logic which has event handlers to do auditing on object create / remove. i want to store username in audit trail, i want to save username in some global place which is session bounded so that i can get the username in my audit module.i dont want to refer System.web, or httpcontext in my businesslogic project.pls help how i can acheive this. i found this article but cudnt understand much.

"Now one option if you want to have your DLL pull the stuff from Session is to abstract out session. So you could define an interface like IStorage, that your library will know how to use. Then you can have a SessionStorage or MemoryStorage class and use IoC to inject the appropiate class into your library classes. This gives you the freedom to code it how you wanted it to be coded without tying your code to Session. Oh and one other benefit if done properly can be used to not tie your code to session in the web either.

View 7 Replies

State Management :: Cache Vs Static Variable?

Sep 24, 2010

I know the big difference, but one thing is confusing me. Cache works only on a single machine on webfarm and to make it globally we use Velocity or memcache.So is static does same, or is it already work globally ?
eg

Cache["someid"] = "value"; //this will only work on single machine cache,

static string abc = "value"; // will this work on single machine or globally ?

View 6 Replies

State Management :: Session Variable Use / IsolatedStorage?

Feb 20, 2010

I am using ASP.NET 2.0I am little bit confuse about using of Session Variable. I have a three page web application. When a user login, after verification of user credentials I get user ID from DB and store this ID in a session variable.Session("USERID") = 56by using this ID I can get 20 different values from database as User Full name, user date of birth, user location, user date of joining, User Commission rate etc. I need some of these values in Page 1, some in page 2 and some values needed in Page 301. After successfully login and getting the User ID, I take all these 20 values from Data Base and store these values in an ArrayList and store this ArrayList in a seesion and whenever I need to use any value I take these values from ArrayList which is save in Session variable.

View 6 Replies

State Management :: Looking For A Way to Declare A Global Variable?

May 14, 2010

I'm looking for a way to declare a global variable (so all pages could see) but personal (so if one user puts some value in it, it won't matter to another user or change his value).Sessions and hidden fields won't do. I've tried working with declaring keys in Web.config but unfortunely, the keys values aren't personal, and all users share the same key value.Another way I was thinking was maybe classes, but perhaps there might be an easier solution?

View 19 Replies

State Management :: Store 2 Arrays In One Session Variable

Apr 21, 2010

I have 2 arrays declared like this :

[Code]....

and i wish to put both in one session variable and then retrieve it to get one array like:

{"intItemID","strCategory","strType"}

View 3 Replies

State Management :: Store An ArrayList Into A Session Variable?

Apr 23, 2010

I'm looking store an ArrayList into a session variable, but am having a few problems. Can you spot anything wrong?

public partial class _Default : System.Web.UI.Page { ArrayList score = new ArrayList(); protected void twist2(object sender, EventArgs e) { int a = 11; int c = RandomNumber(a); score.Add(c); score = (ArrayList)Session["scoreData"]; Result.Text = (c).ToString(); String Result_id = Result.Text; int total = 0; //Session["scoreData"] = score; for (int i = 0; i < score.Count; ++i) { total += (int)score[i]; } Sum.Text = (total).ToString(); String Sum_id = Sum.Text; }

View 3 Replies

State Management :: How To Save Username In Session Variable

Apr 20, 2010

I am building a simple search interface for one of our existing systems. I am using windows authentication. What I would like to do is grab the username of the logged in user via httpcontext.current.user into a session variable on page load and use it in various places on my page. My problem is that when i run my code in debug mode from visual studio it works fine. But when i try to run my code from the browser using localhost it does not work.

View 4 Replies

State Management :: Setting Session Variable From Formview

Apr 13, 2010

I'm building a site (it's amazing how much you can do and still not know what you're doing).I have my visitor login from a login.aspx page and, when authenticated are redirected to a Portal page. On that Portal page at pageload I set a Session variable "UserName" using the User.Identity.Name like this:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If User.Identity.Name <> "" And User.Identity.IsAuthenticated = True Then
If Page.IsPostBack = False Then
Session("UserName") = User.Identity.Name
End If
[code]...

View 4 Replies

State Management :: Storing Datatable In Session Variable?

Oct 28, 2010

I am storing Datatable in Session variable in my project. Is it good practise to do so? The datatable has 20 fields and can run into 1000+ records. Will it hamper my application performance?

View 11 Replies

State Management :: Shared Variable But Specific To One Login?

Apr 28, 2010

I dont know if im writing in a right place. this is about class in App_Data (asp.net) folder that i want to user throughout system. but specifically for one user.

lets say userA login to the system. then system will use classUser
FillProperty and set variable like Name, Username, UserId (a property of his own, the modifier is
shared). the purpose is so that it can be used in any page. it behaves like
user.identity.name (when we want to call name of user that already authenticated)

I can do it fine. but once i test login with UserB in other browser, it change that shared variable with property of userB.what i want is, when A login, he will set the classUser with his data and data that called by him is his data. and when B login, he will do the same, but he will use his data without replacing userA data.here is the code :

-------------- CLASS -------------[Code]....

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved