473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Session, Cookies, QueryString

In web app development you can use session, cookies, querystring to reference
variables you set in a previously in the app.

My question is how does windows let you access a variable value you set in
the previous form.

i am perplexed. I thought you did it somehow with properties, but i don't
see how.

please, please show me.
Feb 27 '06 #1
5 2357
In ASP.NET 2.0, you have a PreviousPage property providing access to the
controls on the previous page, when a submit button has its postUrl property
set to the target page.
Otherwise, you would use Session, Querystring, Cache, or the HttpContext
Items collection depending on your business scenario.
Hope that helps.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"CodeRazor" wrote:
In web app development you can use session, cookies, querystring to reference
variables you set in a previously in the app.

My question is how does windows let you access a variable value you set in
the previous form.

i am perplexed. I thought you did it somehow with properties, but i don't
see how.

please, please show me.

Feb 27 '06 #2
Maybe i am not being clear.

This is a very simple question. My experience thus far is in web application
development. Now in web app development if you want to access a variable you
set in the previous page you can use Session state, or set the variable in
the querystring to the new page.

Windows application development does not have Session state or use query
strings as far as i am aware because it has no constantly refreshing browser
to contend with.

So my question is:
In Windows app development, how can you access a variable you set in a
previous form?

(I am not using .Net 2.0)
Feb 27 '06 #3
CodeRazor wrote:
Maybe i am not being clear.

This is a very simple question. My experience thus far is in web application
development. Now in web app development if you want to access a variable you
set in the previous page you can use Session state, or set the variable in
the querystring to the new page.

Windows application development does not have Session state or use query
strings as far as i am aware because it has no constantly refreshing browser
to contend with.

So my question is:
In Windows app development, how can you access a variable you set in a
previous form?

(I am not using .Net 2.0)


Say you want to access a user id in your "previous" form. Your form
could do a number of things. It could set a semi-global variable, could
be a *return* value of a ShowDialog() method, or it could expose a
property that you'd have to read.

The property method is the one I like, since it's also what the
OpenFileDialog form uses. To use it add something like this to your code:

class MyForm : Form {
string userid;
public string UserID { get { return useride; } }
// rest of the form
}

Then in the code you use to call this form you'd use something like:

class EntryPoint {
static void Main(string[] args) {
string id = null;
using(MyForm form = new MyForm()) {
if(form.ShowDialog() == DialogResult.OK)
id = form.UserID;
}
Trace.WriteLine("Your id is: " + id);
}

}

Of course, this is just a mock-up. The way WinForms are used seems a
lot different to me than the way WebForms are used. You never need to
worry about switching windows. If what you're trying to do is a sort of
"Wizard", I recommend passing the object you are trying to fill to each
form constructor, then the form can fill the parts it is supposed to and
continue. I like using a separate class (EntryPoint) for this:

class EntryPoint {
static SomeObject wizobj;
static void Main(string[] args) {
wizobj = new SomeObject();
using(FormStep1 f = new FormStep1(wizobj)) { f.ShowDialog()}
// ... continue until the wizobj is filled.
}
}

Hope this helps,
Scott
Feb 27 '06 #4
Hi,

You have to keep a reference to the previous form in your new form. also
the parent form needs to make accesible the data you need.

like this:

class Parent:Form{
private string mydata="a piece of data";
public string GetData{ get{return mydata;}} // ...

//show a new form when a button is clicked
public void button1_Click( ... )
{
new Form2( this).ShowDialog();
}

}

class Form2: Form{
Parent theParentForm;

Form2( Parent theForm) { theParentForm = theForm; }

private Form2_OnLoad ( ... .)
{
MessageBox.Show( theParentForm.GetData );
}

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"CodeRazor" <Co*******@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
In web app development you can use session, cookies, querystring to
reference
variables you set in a previously in the app.

My question is how does windows let you access a variable value you set in
the previous form.

i am perplexed. I thought you did it somehow with properties, but i don't
see how.

please, please show me.

Feb 27 '06 #5
Thank you Scott and Ignacio. That is what I was looking for.
I will try out your suggestions.
Mar 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Robert Tweed | last post by:
Does anyone know a good resource discussing the issues involved in session theft? I've read a couple, but none that really address the problem apart from acknowledging that it is a problem; you...
1
by: Don Grover | last post by:
Does any one have an asp page they can share that returns current session details, cookies etc. I can't get session arrays to return in a page.
3
by: PM | last post by:
I'm trying to make a kind of search history containing the 3 last searched words. So I'm using 3 Session Variables: Word1 / Word2 / Word3. In order to get this history working, I need to put the...
14
by: qaz | last post by:
I've always used session cookies in my web sites. However, since more and more people (including me) are starting to disable cookies, I'm beginning to think that I should change my ways and design...
3
by: news.onet.pl | last post by:
Hello I'm biting into the following problem: HTTP is stateless protocol and thus net languages' designer had to find out session. As far as I know session handling in any of the language (PHP,...
3
by: Richard P | last post by:
I am experiencing some browser weirdness. My app uses session state to hide values I prefer to keep out of the querystring. I am testing to see what happens when cookies are fully disabled in IE...
2
by: Arpan | last post by:
In my ASP application, a Session variable takes the following form <% Dim strRec,strCol strRec=Request.QueryString("records") strCol=Request.QueryString("columns") Session("RecCol")=strCol &...
9
by: Jimmy Junatas | last post by:
When we open a window (using client-side jscript ie. window.open("/Site/Popup.aspx?...",...)) from Page1.aspx, the called page Popup.aspx does not have access to the Session variables present in...
4
by: Paul W | last post by:
Hi - I don't want to rely on my users having cookies enabled. If I use Cookieless=True it of course mangles the urls which means there is no browser caching of the pages, so it is slow. ...
6
by: Morten Snedker | last post by:
A user enters a password. Via stored procedure i lookup that (unique) password. If it is found I save the userID to a Session("userID") for later use. I use no other saved variables than this one....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.