Variables - Postback

netpicker9
01-26-2007, 08:57 AM
Display.aspx.vb

Public shared EmpNo, EmpName as string

Protected Sub Page_Load
If Not Me.IsPostBack Then
Dim obj as SomeDll.ClsEmp
EmpNo = obj.GetNO()
EmpName = obj.GetName()
End if
End sub

In this page (Display.aspx), I have 2 dropdown and a button which cases Postback to the same page (Display.aspx)

If I click button or select dropdown, I am able to print the EmpNo, EmpName values to the form..

But, If I left the page for sometime, without taking any action on it and later If I click button, the EmpNo, EmpName variable are showing NULL values..

I used Public Shared to define these variables..
What is the best way to store variable values.. I can't use Sessions or store variable info in database..

Suggest me..

thanks

wayneph
01-27-2007, 06:28 AM
If the user could be away for a long time then the best place to store them is probably in the ViewState. That is stored in the page and passed back to the server every time the pages is posted back. If it's sensitive information, you sould probably encrypt it before putting it in the ViewState.

netpicker9
01-29-2007, 12:04 PM
Thanks wayneph,

I have one more doubt here, in my project we are using WebForm concept(multiple servers).

What is the performace for ViewState in that case? Is that going to work!!

let me know

wayneph
01-29-2007, 12:34 PM
View State has nothing to do with the Farm. It will slow the page down a little bit because that is more data sent to and from the server, but it will make sure that the information is there when it comes back.

I'm not saying put 300 pieces of information there. Just one or two. A few bytes won't kill you're transfer timey.

netpicker9
01-29-2007, 06:52 PM
Hi,

We are migrating a VB6 application to Web (asp.net 2.0).

In Vb6 App, they are using "Public Type" to store variable & values which are accessible through out the application.

What is the similar concept I can use in ASP.net(I am using VB.net language).

I have some limitations here, I can't use Sessions, Cookies

Suggest me please.

Thanks

mcdonnc2004
01-30-2007, 03:46 AM
You can use Application Variables to store data in that way. Storing something in an Application Variable is very simple. Lets say I wanted to store a number from a textbox in a variable called OrderNum. The code would be:

Application("OrderNum") = TextBox1.Text

Then, if you wanted to display this information on a Label you would do:

Label1.Text = Application("OrderNum")

That should help accomplish what you want to do.

netpicker9
01-30-2007, 08:25 AM
I think we can't use Application variables in Web farm(in which an application is hosted by multiple servers)

becuase my application is using the Web farm concept..

Please let me know if I am wrong..

If I am correct, What is the other way / suggestion?

wayneph
01-31-2007, 07:19 AM
Store the Data in a Database. All of your servers will be able to pull it from there.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum