hi
Which one is better when we want to redirect to a new page in asp.net : using a link button and then Response.Redirect OR using an html link?
hi
Which one is better when we want to redirect to a new page in asp.net : using a link button and then Response.Redirect OR using an html link?
I would use the anchor tag. It seems that with the redirect you are doing extra work with the round trip for not much gain besides using the link button control (at least this is what I am surmising from your question, there are valid reasons to use it). Also (not that this will likely make a difference in your case) it does cause and additional status code to be sent to the browser (302), telling the client application something is potentially amiss). If you are working on a highly secure site and or have non-browser applications accessing the page to pull information, this could be a problem.
Actually you have a third option which might suit your needs. Depending on the way your pages are setup and what you need to do, you can use Server.Transfer also.
Depends on your needs:
<a>
tag if there's no need for you to do anything with the form/page you're directing fromresponse.redirect
if you need information from the form before moving on to the next page, for example to update session states or store intermediate results. If you are just linking to another page with a static URL, use an HTML anchor link. It will have better performance and only requires code in one place: the page.
If you need to perform operations on the server before the redirect, including manipulating the URL (e.g. dynamically creating querystring parameters), then use a server control (button, link, linkbutton).
If you want to use a button instead of a link just for the way it looks, you can use javascript to change the location of the page in the button's onclick also saving you a trip to the server.