C# - Temporary Or Session Variable - Want To Add A Decimal Number To This Variable

Dec 2, 2010

What would be the proper syntax in ASP.NEt 3.5 C# to assign a TextBox value to a temporary or session variable to be manipulated (added, subtracted, multiplied, divided) at different points in the application? I want to add a decimal number to this variable in almost every instance as well.

View 3 Replies


Similar Messages:

JQuery :: Grab A Global Variable Or Session Or View State Variable In The Javascript?

Dec 9, 2010

can we grab a global variable or Session or View State variable in the javascript or using jquery?

View 2 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

How To Store A Value Into A Session Variable And Load From That Value Back From The Session Variable

Nov 22, 2010

Currently in an .aspx file, I am storing a value (filename that was created in that session) in an hidden text box. When the user clicks on the "Print" labeled Hyperlink control, it opens the file that was stored in the hidden text box control. But when the user goes to different screen (in the same session), I loose the filename value that is stored in the hidden text box control. So I would like to store the filename variable in a session variable. So that if the user leaves this .aspx file and comes back to this .aspx file I can load the value into the hidden text box from the session variable.

View 11 Replies

Which Is The Best Usage Session Variable Or Global Variable

May 25, 2010

I have the dataset. in this i am having total 20 tables with huge amount of data..I want use this data over all the page..so where i can keep this data..

before i used viewstate but the viewstate data is render to page every postback ..so this time the page size is increasing(interanlly viewstate is rendered to page)..so performence wise it was very slow..

Now i change my logic insted of viewstate to i used Globel Dataset on Page Level.. now the performence wise better than viewstate..

i used Like shared dsControls as Dataset at top of the page..so every time i use this dataset..

my quesation is session is better or Globel variable is better way use in my situavation..

View 3 Replies

State Management :: Variable To Store Temporary Page Data?

Sep 29, 2010

I'm working on a web page that is going to be used to enter data into a database. The page is going to be dynamic in that the user has the ability to add a row to the table with the same fields, ie lname1, fname1, mi1 then lname2, fname2, mi2

I'm wanting to use a variable to keep track of how many lines there are so that when I generate the added line I am creating a new field with the ID of lname+# . Whats the best way to do this, a global variable, session variable? As side note, first time programming in .Net or C#.

View 3 Replies

Web Forms :: Data Inserted In Temporary Variable Getting Lost In Web Method

Aug 26, 2012

It is  working on button click , becuase i when store the values from datalist into my database , the values got inserted .. but when i am trying to store those value in temporary datatable its not working

[WebMethod]
public static ProductDetails[] DisplayMessage(string name, string price,string obj, string id) {
string emailid = HttpContext.Current.User.Identity.Name; ;
string date = DateTime.Now.ToString();
string s = HttpContext.Current.User.Identity.Name;

[Code] ....

View 1 Replies

State Management :: Global.asax To Load Up Several Session Variable When A Session Starts?

Sep 14, 2010

I added the following code to global.asax to load up several session variable when a session starts. I'm assuming that when a page goes to use the variable that I should be

1) checking at the page level that the value is valid not 0 when its not expected to be 0, not a zero-length string when its expected to have a length

2) have code at the page level that sets the values if the values have not been set as when the Session timeout, ideally putting the code in a class derived from Page and then deriving all of my pages from the new class so that the code does not have to be repeated in every page

[Code]....

View 7 Replies

State Management :: Session Variables And Tabs / Is There A Way To Reset The Session Variable

Nov 11, 2010

I have some code in my page load event where I just want to fire once when the user opens the Browser. The only issue is if you open a new tab with the same website the session variable does not reset. Is there a way to reset the session variable when you open a new tab or do you have to take the whole web browser down for it to clear the session variable.

In Global Page:

[code]....

View 2 Replies

State Management :: Session Variable Persisting Even After Abandoning A Session - Closing Browser Windows

Aug 5, 2010

I have been spending a better part of a week trying to track down why I am not able to clear all session variables in a web app (vs 2010, vb.net). What I have tracked it down to is that when I remove or abandon sessions that my html pages or codebehind access, it works, but for some reason in any of my class files where I use "Public Shared strConnection as String = HttpContext.Current.Session("strConnection").ToString" to access a session variable, it finds the old one and not the current one. I have to wait for it to time out, go in again, and it will find the new one.

I do not use Linq, and there is only one place in the whole web app that I place the connection string in a variable whcih is when a person logs in. It points them to the correct database. The sqlconnection is set for all of my listviews in Page_Init to make sure that they aren't using any session variable that they create on their own. Interestingly enough that if I use debug to go in each time, exit debug, enter debug again trying to access a different database, it works correct each time. I assume that debug is correctly killing the session variable for the classes for me.

View 4 Replies

AJAX :: Cascading Dropdownlists / Tried A Session Variable But It Comes Up With Session Is Null?

Jul 29, 2010

I have some cascading dropdownlists using the ajax toolkit I have a set up datatables in an xsd file. Then use these in a webservice to populate all the fields ... this all works great but now i need to pass an additional paramter to the first dropdownlist ( a date) but don't know how to do this? The method is below...

[Code]....

The other code is:

[Code]....

The first change would be to the tableadapter to add a param to the code i.e

AuditWebDS.TeamsDataTable teams = teamsAdapter.GetTeams(calldate);

but how do i get the calldate param to the webservice method... i tried a session variable but it comes up with session is null ? Is there another better way?

View 1 Replies

How To Insert A Variable Number Of Records In One Go

Mar 18, 2011

I need to run a variable amount of insert statements. Is it best to run through a loop and execute the query one at a time? Or, is there a way to send all the inserts in one go?

View 5 Replies

Web Forms :: Add Variable Number Of Some Control?

Apr 7, 2010

I have a project with a database. There is a table in the database which store news. The news are composed by a headline and a link to a web page where you can read the news.

I want to make a unordered list, where, for each element in a database table, there will be a line in the list, with the news headline displayed by a Label control followed by a Hyperlink control that takes you to the news webpage.

How can I construct a page with a variable number of controls?

I was doing something like this:

<% foreach(News news in NewsTable) { %>
<asp:Label ...></Label>
<asp:HyperLink ...></HyperLink>
<% } %>

But the result of this is that I have the same Label and HyperLink drawed several times.

View 2 Replies

Web Forms :: Convert System.Drawing.Image Variable To Byte Variable?

Oct 7, 2010

I got a variable of type System.Drawing.Image and need to convert it to a variable of type byte so I can store the image in the database. Can someone show me how to do that in VB.NET code.

View 2 Replies

C# - Hidden Variable Vs Server Variable Accessing On Client Side In Javascript

Jul 14, 2010

I'm evaluating two options of accessing a server side data on client side. Little bit confused about the efficiency or may be you can call it as finding best approach to do it.

I need to access a server side data may be an integer value in javascript on client side. I know about two options to do it.Create a public variable or property on server side and set it to javascript variable on client side as below:

var value = eval(<% =value %>);

Create a asp hidden variable and set value in this hidden variable from server side and access it through javascript using document.getElementById().

Which is the best approach and what are the pros and cons?

View 1 Replies

Declare Variable In C# / Use VAR (explicit Declaration) Or The DataType When Declaring A Variable (implicit)?

Sep 7, 2010

Possible Duplicate: Use of var keyword in C# Hi, I am pretty new in C#,I would like to know the best practices in declaring variables.I know it is possible to use VAR (explicit declaration) or the DataType when declaring a variable (implicit).

View 3 Replies

BC3016: Variable 'myConnection' Hides A Variable In An Enclosing Block?

Jul 16, 2010

I'm am not quite sure why I am getting this error.

Dim numUsers as Integer
Using myConnection as New System.Data.SqlClient.SqlConnection("Data Source=(local);InitialCatalog=dbtest;Integrated Security=True")
Dim queryString As String = "SELECT COUNT(*) AS Num_Of_User FROM tblusers WHERE username=@username AND password=@password"
Using myCommand as New System.Data.SqlClient.SqlCommand(queryString, myConnection)
myConnection.Open
myCommand.Parameters.AddWithValue("@username", requestName)
myCommand.Parameters.AddWithValue("@password", requestPass)
numUsers = myCommand.ExecuteScalar()
End Using
End Using

This error occurs on the first using statment.

View 1 Replies

Processing Variable Number Of Form Fields?

May 17, 2010

I am working on a form which displays information about orders. Each order has a unique id, but they are not necessarily sequential on the form. Also, the number of fields can vary (one field per row on the form). The input into the form will not be mapped straight into the database, but will be added to the current value in the database, and then saved. An example of the form is in the picture below - the callout on the right shows the id for each row.

I know how to generate the form like this, but I can't work out how I can easily process each of these rows reliably. I also know how to give each of the fields a unique identifier, like name="order-23" or name="order[23]", but how can I translate that name so that I can update the related record in the database?

View 3 Replies

Variable Hides A Variable In An Enclosing Block Error

May 14, 2010

have a look at this simple code snippet

[Code]....

Here second declaration of x gives error that "variable 'x' hides a variable in an enclosing block. I wonder why this error is not given for second 'i' variable declared in second for loop?

Since i am declaring second x in a separate for block, why this error is given for variable second x ?

View 4 Replies

Handling Variable Number Of Fields In WebForms Page?

Dec 1, 2010

I wanted to gather some methods on how to add a variable number of fields to my form (with Add New and Remove buttons). I know that ASP.NET MVC has easy methods, but I'm unable to find any easy methods for WebForms.

Here's what I've used so far:

Adding a new UserControl to a PlaceHolder on PostBack (I've had to fiddle with ViewState to make this work correctly, huge pain) Adding a new row to a grid and having a template field in a grid (works decently but kind of awkward) Actually having several fields on the form by default and hiding/showing them dynamically (fairly easy but you have a set number of fields.)

View 1 Replies

DataSource Controls :: SqlDataSource Variable Number Of Parameters

Mar 7, 2011

I should perform a Query like this Select * from produtcts where model like @MODEL Now if model is selected from combobox, it should be Select * from produtcts where model like '%MODEL1%' while, if selected chooise is null, it should be like each element in my combobox. how should i do this (in SqlDataSource)

View 5 Replies

State Management :: What Is Session And What Is Session Variable

Apr 21, 2010

I am new to asp.net Can you please guide me what is session and session variables ? Please I don't need a comparision of asp session and asp.net session because I don't know anything about asp. I have saw many articles on types of session as well. But still I cant understand exectly what is session and what are session variables in asp.net ?

View 9 Replies

Web Forms :: Using A Custom Control A Variable Number Of Times On A Page?

Feb 2, 2011

I'm a newbie here. I have created a custom control that requests a set of data from a user. However, I want to be able to have a variable number (dictated by the user) of these data sets entered on each page. How can I create and refer to a variable number of instances of a user control on a single page? It's hard to explain in words, but I'm basically looking for some way to do what amounts to the following:

[code].....

Is there a straightforward way of doing this? I haven't been able to find a clear answer via Google, which brought me to this group.

View 2 Replies

Forms Data Controls :: Embeb A Variable Number Of Videos?

Aug 21, 2010

I need to provide some alternate content for my non-Flash users. I have a directory of video files that is scanned using the DirectoryInfo() function, and I want to use the results to embed all files ending in ".mov" in QuickTime players on a web form. How would you approach this? Right now I am using the count on the array of videos to determine how many times to repeat the embed code. But this seems inelegant.

Is there a way to have a single QuickTime player.ascx control that gets duplicated according to the number of videos available for display?

View 1 Replies

Application Variable Versus Web.Config Variable

Aug 24, 2010

Which is better from a performance perspective?

Accessing a Global Application Variable (Application["foo"])

versus

Accessing an AppSetting variable from the web.config

Does .NET Cache the AppSetting variables so that it is not accessing the web.config file with every use?

View 2 Replies







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