473,383 Members | 1,716 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,383 software developers and data experts.

Beginner question re postback

Hello,

I have been wondering that everytime I do a submit on a button/form
(postback) it is using the same webform on the CS, how do I goto another
webform once I have done a postback and processed any code?

When I finally do goto another webform from the postback will all variables
and settings be sent along to this new web form?

Thanks

J
Nov 18 '05 #1
5 1176
In Page Load always test for IsPostback and Not IsPostback so that when the
page is hit the first time different code is run.

If you click a button, then Page Load will run but maybe since IsPOstback =
True then you won;t do anything there.
Then your button handler code will run and you can do stuff.
The last line of code might be:
Response.Redirect("SomeOtherPage.aspx")

The variables will NOT be available on the next page unless you do
something.
Cache
Session
QueryString
etc.

e.g you could store them in Cache or Session during your button handler code
and then pull them out
when you get to the next page.

Or you could put them in a querystring:
Response.Redirect("SomeOtherPage.aspx?MyVariable=x yz")
--
Joe Fallon


"John W" <jw*****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hello,

I have been wondering that everytime I do a submit on a button/form
(postback) it is using the same webform on the CS, how do I goto another
webform once I have done a postback and processed any code?

When I finally do goto another webform from the postback will all variables and settings be sent along to this new web form?

Thanks

J

Nov 18 '05 #2
In many cases, you don't need to go to another page since you can test for
IsPostBack and process the postback differently from the first page load.
If you do need to go to another page and have the first page data available
there, you can store the values yourself as mentioned in the earlier reply
or you can use server.transfer(newpage) and the new page's code will be
processed with the first page's form data available to it.
"John W" <jw*****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hello,

I have been wondering that everytime I do a submit on a button/form
(postback) it is using the same webform on the CS, how do I goto another
webform once I have done a postback and processed any code?

When I finally do goto another webform from the postback will all variables and settings be sent along to this new web form?

Thanks

J

Nov 18 '05 #3
Ian
thanks joe,

great, any ideas which is the best route ?? you listed a few, are there any
pros and cons?

cheers

J
"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:eb**************@TK2MSFTNGP10.phx.gbl...
In Page Load always test for IsPostback and Not IsPostback so that when the page is hit the first time different code is run.

If you click a button, then Page Load will run but maybe since IsPOstback = True then you won;t do anything there.
Then your button handler code will run and you can do stuff.
The last line of code might be:
Response.Redirect("SomeOtherPage.aspx")

The variables will NOT be available on the next page unless you do
something.
Cache
Session
QueryString
etc.

e.g you could store them in Cache or Session during your button handler code and then pull them out
when you get to the next page.

Or you could put them in a querystring:
Response.Redirect("SomeOtherPage.aspx?MyVariable=x yz")
--
Joe Fallon


"John W" <jw*****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hello,

I have been wondering that everytime I do a submit on a button/form
(postback) it is using the same webform on the CS, how do I goto another
webform once I have done a postback and processed any code?

When I finally do goto another webform from the postback will all

variables
and settings be sent along to this new web form?

Thanks

J


Nov 18 '05 #4
There are whole books on the subject.
I don't think anything I can say in a few lines is going to help!

Session is extremely useful and user specific. Requires lots of RAM.
Viewstate is also user specific - requires more traffic over the wire so it
is slower for the end user.
Querystring is great for passing small pieces of info in the URL like a PK
value.

Application is for all user but should be avoided in favor of Cache which is
the same thing but with more features.
(Application is more for backward compatibility.)
Cache can be set with priorities and expirations. You can also set
dependencies to expire it.
Very useful for application wide things that should be stored in RAM.

Server.Transfer is useful as stated in another message.
The main thing I don't like about it is that the URL does not change for the
user.
I also recently read that there may be a bug in it. Something about some
events not running correctly (or as anticipated) when using it. I tend to
stay away from it for these 2 reasons. YMMV.

--
Joe Fallon

"Ian" <ia*********@hotmail.com> wrote in message
news:eF**************@TK2MSFTNGP09.phx.gbl...
thanks joe,

great, any ideas which is the best route ?? you listed a few, are there any pros and cons?

cheers

J
"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:eb**************@TK2MSFTNGP10.phx.gbl...
In Page Load always test for IsPostback and Not IsPostback so that when the
page is hit the first time different code is run.

If you click a button, then Page Load will run but maybe since

IsPOstback =
True then you won;t do anything there.
Then your button handler code will run and you can do stuff.
The last line of code might be:
Response.Redirect("SomeOtherPage.aspx")

The variables will NOT be available on the next page unless you do
something.
Cache
Session
QueryString
etc.

e.g you could store them in Cache or Session during your button handler

code
and then pull them out
when you get to the next page.

Or you could put them in a querystring:
Response.Redirect("SomeOtherPage.aspx?MyVariable=x yz")
--
Joe Fallon


"John W" <jw*****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hello,

I have been wondering that everytime I do a submit on a button/form
(postback) it is using the same webform on the CS, how do I goto another webform once I have done a postback and processed any code?

When I finally do goto another webform from the postback will all

variables
and settings be sent along to this new web form?

Thanks

J



Nov 18 '05 #5
There are whole books on the subject.
I don't think anything I can say in a few lines is going to help!

Session is extremely useful and user specific. Requires lots of RAM.
Viewstate is also user specific - requires more traffic over the wire so it
is slower for the end user.
Querystring is great for passing small pieces of info in the URL like a PK
value.

Application is for all user but should be avoided in favor of Cache which is
the same thing but with more features.
(Application is more for backward compatibility.)
Cache can be set with priorities and expirations. You can also set
dependencies to expire it.
Very useful for application wide things that should be stored in RAM.

Server.Transfer is useful as stated in another message.
The main thing I don't like about it is that the URL does not change for the
user.
I also recently read that there may be a bug in it. Something about some
events not running correctly (or as anticipated) when using it. I tend to
stay away from it for these 2 reasons. YMMV.

--
Joe Fallon

"Ian" <ia*********@hotmail.com> wrote in message
news:eF**************@TK2MSFTNGP09.phx.gbl...
thanks joe,

great, any ideas which is the best route ?? you listed a few, are there any pros and cons?

cheers

J
"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:eb**************@TK2MSFTNGP10.phx.gbl...
In Page Load always test for IsPostback and Not IsPostback so that when the
page is hit the first time different code is run.

If you click a button, then Page Load will run but maybe since

IsPOstback =
True then you won;t do anything there.
Then your button handler code will run and you can do stuff.
The last line of code might be:
Response.Redirect("SomeOtherPage.aspx")

The variables will NOT be available on the next page unless you do
something.
Cache
Session
QueryString
etc.

e.g you could store them in Cache or Session during your button handler

code
and then pull them out
when you get to the next page.

Or you could put them in a querystring:
Response.Redirect("SomeOtherPage.aspx?MyVariable=x yz")
--
Joe Fallon


"John W" <jw*****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hello,

I have been wondering that everytime I do a submit on a button/form
(postback) it is using the same webform on the CS, how do I goto another webform once I have done a postback and processed any code?

When I finally do goto another webform from the postback will all

variables
and settings be sent along to this new web form?

Thanks

J



Nov 18 '05 #6

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

Similar topics

4
by: anonymous | last post by:
Hi Folks, I have a form with two Dropdown list boxes, which get loaded with data from Database. DropDownList1 gets data from Table1 and DropDownList2 gets data from Table2 Table1 has a...
2
by: Jade Seguin | last post by:
Hello, Hope somebody can help me with this cause I'm a ASP.NET beginner. I've created A DataGrid, and I added few BoundedColumns, and in my Page_Load section I added few TemplateColumns through...
3
by: Chung Hang Shum | last post by:
I'm a beginner in ASP.Net. I'd wroten mange asp code before and now I need to transfer them from asp to asp.Net. In classical ASP you can write code like this: <% If strRequest = "ConfirmPasswd"...
0
by: Antoine | last post by:
Forgive me as a beginner in asp.net. I wanted to ask some simple but clear questions, at least I hope they are. Ive seen a control in asp.net that works with codebehind and the good thing about...
7
by: Michael Groeger | last post by:
Hi all, I have designed user controls. One search control where I can search for items in the database and show them in a grid. This control also has a button which simply exposes it's click...
2
by: Chris | last post by:
Hi all, I've recently started learning ASP.Net and have a few questions mostly regarding best practice. As postback uses JS is it normal practice to check if the browser supports/has JS...
9
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I followed first walk through sample from http://ajax.asp.net/docs/tutorials/IntroductionUpdatePanel.aspx to create my first testing page, The problem is after I clicked that botton, it...
1
by: 47computers | last post by:
I have a couple of DropDownLists in a DetailsView control (your classic country/state lists) and I need one to be populated based on the current selection of the other. Currently this works fine...
2
by: furqi | last post by:
hello every body i am currently a beginner in asp.net i am currently watching msdn videos of "beginners developers learning" i am on the topic of application state so i got confused on a topic of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.