By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,910 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,910 IT Pros & Developers. It's quick & easy.

Load Page. VB vs Javascript. Need opinion. Thank You.

P: n/a
Hello,

I am working on an ASP.NET/VB web site.
I have several links including menu links.

Considerer a want to load a page named page.aspx.

I can do it using javascript. Or using this code:
Sub loadPage(sender As Object, e As System.EventArgs, pageURL as
String)
Response.Redirect(pageURL)
End Sub

What are the advantages or disadvantages of each method?

Which one should I use?

Thanks,
Miguel

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in news:
#J**************@TK2MSFTNGP12.phx.gbl:
I can do it using javascript. Or using this code:
Sub loadPage(sender As Object, e As System.EventArgs, pageURL as
String)
Response.Redirect(pageURL)
End Sub

What are the advantages or disadvantages of each method?


Javascript can be disabled.

Server side will require a round trip. But a server side transfer will
allow you to log what happened (or do additional processing).

Personally I'll choose a sever side transfer.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2

P: n/a
Think of these software entities as tools. In that context, think of one as
a Framing hammer, and one as a Finishing hammer. Now, in that context, how
would you answer the following question:
What are the advantages or disadvantages of each method?
Answer: There are no "advantages" or "disadvantages" to either. There are
properties and characteristics. Neither good nor bad, unless used in some
context. For example, a Framing hammer is perfect for framing. A Finishing
hammer is perfect for finishing. But a Framing hammer will make a mess if
you use it for finishing, and a finishing hammer will take forever to build
a frame.

Again, using the hammer analogy, how would you answer the following:
Which one should I use?
Answer: Use the tool that has the characteristics and properties that are
appropriate for the given situation. If you're building the frame of a
house, use a framing hammer. If youre putting in moulding, use a finishing
hammer.

So much for the philosophy. Now let me answer your specific questions, posed
in a more appropriate fashion:

What are the characteristics and properties of each method?

Actually, you have more options than the ones you mentioned, such as:

Client-side:
JavaScript
Hyperlink
Server-side:
Response.Redirect
Server.Transfer

And a few others that are much less common, and used for special purposes.

On the client side, a hyperlink is the simplest method to load a different
document into the browser, and if you're strictly talking about links in a
menu, I would go with that. Remember that the links can also include
QueryStrings to pass data to the new page. You can use JavaScript if you
need additional client-side processing, need to open the page in a new
window (which you can also do with a hyperlink, but with less control over
the window), or for somewhat more complex situations.

On the server side, Response.Redirect is often useful, as it causes the
browser to make a second request for the new document. The Redirect
directive is added to the HTTP headers in the Response, causing the browser
to load the new document. With Response.Redirect, you can use a QueryString
to send data to the new page. Note that with Response.Redirect, you are
sending a GET request for the new page. Server.Transfer can be useful in
situations where you need to transfer server-side resources and memory from
one page instance to the other. Note that Server.Transfer does NOT tell the
browser to request a different page, but transfers server-side processing to
the new page, and the browser "thinks" it is still looking at the same page
(URL).

When should I use one or the other?

Again, a hyperlink is the simplest and fastest way of transferring to a new
page. with the addition of a QueryString to the hyperlink, you can also send
data to the new page. JavaScript is also fast, but a little more complex,
and is useful in situations where you need to do additional CLIENT-side
processing, or have control over a new window, such as resizing it, or
setting up the status bar, and other browser elements in the new window.

Response.Redirect can be the simplest way of transferring to a new page, if,
for example, you have some server-side condition that changes and requires a
redirect to a new page. Rather than returning the same page to the client,
and requiring additional client-side processing to transfer, you can do the
Redirect which causes the browser to request the new page, without looking
as if it had received the first page in the first place. However, it should
be noted that Response.Redirect actually causes the browser to make TWO
Requests, one for the first page, and one for the redirected page, and
involves some network latency. Server.Transfer has the advantage of not
requiring a second Request from the browser, but remember that it returns a
new page with the same URL as the original page. Server.Transfer can be
useful when you want to do a partial Response from one page, and finish it
from another.

If you keep these characteristics of each method in mind, it should become
apparent at what time(s) to use which method(s).

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Hello,

I am working on an ASP.NET/VB web site.
I have several links including menu links.

Considerer a want to load a page named page.aspx.

I can do it using javascript. Or using this code:
Sub loadPage(sender As Object, e As System.EventArgs, pageURL as String)
Response.Redirect(pageURL)
End Sub

What are the advantages or disadvantages of each method?

Which one should I use?

Thanks,
Miguel

Nov 19 '05 #3

P: n/a
Thanks Kevin for your description of the most common options I have.
I will be useful in the future.

Cheers,
Miguel

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ke***@DIESPAMMERSDIEtakempis.com:
Think of these software entities as tools. In that context, think of one as
a Framing hammer, and one as a Finishing hammer. Now, in that context, how
would you answer the following question:

What are the advantages or disadvantages of each method?

Answer: There are no "advantages" or "disadvantages" to either. There are
properties and characteristics. Neither good nor bad, unless used in some
context. For example, a Framing hammer is perfect for framing. A Finishing
hammer is perfect for finishing. But a Framing hammer will make a mess if
you use it for finishing, and a finishing hammer will take forever to build
a frame.

Again, using the hammer analogy, how would you answer the following:

Which one should I use?

Answer: Use the tool that has the characteristics and properties that are
appropriate for the given situation. If you're building the frame of a
house, use a framing hammer. If youre putting in moulding, use a finishing
hammer.

So much for the philosophy. Now let me answer your specific questions, posed
in a more appropriate fashion:

What are the characteristics and properties of each method?

Actually, you have more options than the ones you mentioned, such as:

Client-side:
JavaScript
Hyperlink
Server-side:
Response.Redirect
Server.Transfer

And a few others that are much less common, and used for special purposes.

On the client side, a hyperlink is the simplest method to load a different
document into the browser, and if you're strictly talking about links in a
menu, I would go with that. Remember that the links can also include
QueryStrings to pass data to the new page. You can use JavaScript if you
need additional client-side processing, need to open the page in a new
window (which you can also do with a hyperlink, but with less control over
the window), or for somewhat more complex situations.

On the server side, Response.Redirect is often useful, as it causes the
browser to make a second request for the new document. The Redirect
directive is added to the HTTP headers in the Response, causing the browser
to load the new document. With Response.Redirect, you can use a QueryString
to send data to the new page. Note that with Response.Redirect, you are
sending a GET request for the new page. Server.Transfer can be useful in
situations where you need to transfer server-side resources and memory from
one page instance to the other. Note that Server.Transfer does NOT tell the
browser to request a different page, but transfers server-side processing to
the new page, and the browser "thinks" it is still looking at the same page
(URL).

When should I use one or the other?

Again, a hyperlink is the simplest and fastest way of transferring to a new
page. with the addition of a QueryString to the hyperlink, you can also send
data to the new page. JavaScript is also fast, but a little more complex,
and is useful in situations where you need to do additional CLIENT-side
processing, or have control over a new window, such as resizing it, or
setting up the status bar, and other browser elements in the new window.

Response.Redirect can be the simplest way of transferring to a new page, if,
for example, you have some server-side condition that changes and requires a
redirect to a new page. Rather than returning the same page to the client,
and requiring additional client-side processing to transfer, you can do the
Redirect which causes the browser to request the new page, without looking
as if it had received the first page in the first place. However, it should
be noted that Response.Redirect actually causes the browser to make TWO
Requests, one for the first page, and one for the redirected page, and
involves some network latency. Server.Transfer has the advantage of not
requiring a second Request from the browser, but remember that it returns a
new page with the same URL as the original page. Server.Transfer can be
useful when you want to do a partial Response from one page, and finish it
from another.

If you keep these characteristics of each method in mind, it should become
apparent at what time(s) to use which method(s).

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello,

I am working on an ASP.NET/VB web site.
I have several links including menu links.

Considerer a want to load a page named page.aspx.

I can do it using javascript. Or using this code:
Sub loadPage(sender As Object, e As System.EventArgs, pageURL as String)
Response.Redirect(pageURL)
End Sub

What are the advantages or disadvantages of each method?

Which one should I use?

Thanks,
Miguel


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.