Are Postback and Round Trip to the Server the same thing?

T

Tony Girgenti

Hello.

I'm trying to undetrstand ASP.NET 2.0 and javascript.

When i have a button and i click on it and i see the web broswer progress
bar at the bottom do something, does that mean that there is postback
occurring? Does that mean a round trip to the server occurred?

I keep reading javascript articles and tutorials that say "improve the
client-side experience to be more responsive and quicker", but the articles
always use controls and javascript that have the "runat=server" in them.
Doesn't that mean that the javascript is executed on the server?

Any help would be gratefully appreciated.

Thanks,
Tony
 
M

Mark Fitzpatrick

Tony,
I think you may be missing part of the articles. A postback means
that information is sent to the computer as you have mentioned. A roundtrip
means that you have done a postback, and received data. The JavaScript
factor probably comes into play thanks to a technology called AJAX. AJAX is
basically a javascript framework that enables a web page to perform a
postback on only certain parts of the page, and not the whole page. Only the
portion that is under control by the AJAX routines is updated and worked on.
This avoids posting back a full page, causing flicker and longer delays.
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

Yes, that little progress bar indicates a standard postback, which is a
round trip to the server.
There are other ways to do round trips to the server that are virtually
invisible to the user, and less disruptive for them. The main way is AJAX.
AJAX makes web pages behave more like windows applications. Instead of
doing a normal postback, AJAX allows a web page to stay responsive to the
user while the web page communicates silently with the web server in the
background. AJAX is based on JavaScript and Xml.

Here's more info:
http://SteveOrr.net/articles/Ajax.aspx
 
T

Tony Girgenti

Hello Mark.

A postback means the page is sent to the server computer? A roundtrip means
you have sent a page to the server and it has sent back a reply?

I can't do javascript without AJAX? That's the way i interpret your reply,
and from what i read, that is not true.

I'm still unsure about client-side script. Does this mean that i should be
able to interact with the user in the web page without doing postback or
roundtrip?

Thanks,
Tony
 
T

Tony Girgenti

Hello Steve.

Thanks for your information. I will certainly need some time to read and
understand your article.

I thought it would be better for me to understand javascript and ASP.NET 2.0
before trying to getting into AJAX. Do you agree?

Thanks,
Tony
 
C

Cowboy \(Gregory A. Beamer\)

Adding to the bits already mentioned. Here is the basic primer:

Everything on the world wide web (browser based Internet) uses request
(browser asking for something) and response (server replying with
information). There are two ways to request: GET and POST. GET is a request
that has no form collection associated and is generally associated with
either typing an address in the browser or clicking a link. POST is when you
are posting back form elements. A roundtrip is a complete cycle, including
both the Request (POST or GET) and Response.

NOTE: There is a Request object, which you can use to pull information sent
from the browser, and a Response object, which you can use to push
information back. This makes sense when you think about the cycle above.

In ASP.NET, by default, all elements are inside a <form> tag, so every
control you touch contacts the server using POST, which is why Microsoft
calls it a PostBack. A roundtrip is a complete Request and Response, so it
includes both the Postback and the response to the postback.

NOTE: In ASP.NET, IsPostback is your friend. Most of your Page_Load shoudl
be in a block marked IsPostBack = False or "Not IsPostback", as you should
handle the majority of postback work in the control event that was fired
when the user clicked on something and caused the postback.

JavaScript can enrich the user experience by handling events client side.
For example, you have a set of dropdowns that are dependent on each other.
If the user selects Jaguar (car model), you want to respond with a list that
has S-Type, X-Type and XJ, for example. Using JavaScript, you can load all
of this into an array on the client side and adjust the text in the
dropdownlist based on user's model choice. This can be done without AJAX, as
you can hard code huge lists on the client.

AJAX, or Asynchronous JavaScript And XML is a blend of JavaScript and
XmlHttp Postback capabilities. Technicially, this does a post to a web
service and gets the new elements back. It is not considered a PostBack in
Microsoft talk, as the entire page is not refreshed, only the AJAX enabled
parts. This also can enrich the user's experience, especially on a slower
connection, as the page does not completely have to redraw. But, the lag
time for AJAX can still be noticeable on slow connections, so keep the
updates as small as possible.

Should you learn ASP.NET before AJAX? Probably, but not due to having to
learn one before the other, but rather to avoid biting off more than what
you can chew in one session. Should you learn JavaScript before AJAX? No, if
you are using Microsoft's ASP.NET AJAX, where you are not responsible for
learning the JavaScript. Then, should you learn JavaScript? Yes, unless you
want to rely on tools and their limitations. The deeper your understanding
of underlying concepts, the more valuable you become as an
employee/consultant, as most developers are lazy and do not learn what is
going on underneath the hood.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
 
T

Tony Girgenti

Hello Cowboy.

Thanks for your very intense and informative reply. It took me a little
while to ingest it and understand it.

Other questions that i have. Is there ever a situation where you have a
postback but not a round trip? I'm asking this because of what Mark
Fitzpatrick wrote in his reply to my question. I just can't imagine that a
browser would start a postback and the server not respond to complete the
round trip.

It sounds like you are suggesting that learning javascript is not necessary
to learn ASP.NET AJAX, but i should learn javascript to have an underlying
understanding of ASP.NET AJAX.

I am trying to learn javascript, but what i don't understasnd about what i
am reading, which is why i started this post in the first palce, is why do
the javascript articles/examples always use the asp: type of controls which
have the runat=server. If i want to use javascript for my purposes, should
i use the html buttons?

Thanks,
Tony
 
J

Jasbird

Hello Mark.

A postback means the page is sent to the server computer? A roundtrip means
you have sent a page to the server and it has sent back a reply?

I can't do javascript without AJAX?

No. You can do javascript with anything - so long as your client has
their javascript switched on. In general, for it to work, asp.net needs
javascript switched on.

You can't do Ajax without javascript.
I'm still unsure about client-side script. Does this mean that i should be
able to interact with the user in the web page without doing postback or
roundtrip?

A postback is done by sending the form contents to the server either as
1) a form or as 2) a querystring.

Ajax sends content to the server using a 3rd method, which is a callback
- this is designed to return xml data to the client which can then be
inserted into the web page.

You can interact with the client using these callbacks - but there is a
round-trip - however that Ajax round-trip is faster because you cut out
the normal page loading - which is very code intensive.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top