Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2005, 05:37 AM
Authorized User
 
Join Date: Oct 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to richie86
Default Help with link to other page by button in C#

When writting code in ASP.net using c#, what is the code that we use to link to other page, with not using the hyperlink or link button.
erm it smth like code below in VB

Form.load
form.hide

is that anyone can help me? Thanks alot:)

 
Old October 28th, 2005, 01:09 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

On the button click event of the button try:
Response.Redirect("page name");

 
Old October 28th, 2005, 04:02 PM
Authorized User
 
Join Date: Oct 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to richie86
Default

oh thanks, its work. I had found another code is
Server.Transfer("filename"); but it only can use to link the page under same folder. btw the
Response.Redirect("page name");
izzit not necessary that must b a URL ? like we can put a folder name follow by filename?
EG
Response.Redirect("\folder\abc.aspx");

 
Old October 29th, 2005, 12:50 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Yes you can do that. I just struggled with the syntax. It is very easy.
DON'T put a "/" in front of the folder name, it will not work.

In your case use Response.Redirect("folder\abc.aspx");

This is assuming that there is a folder named "folder" under the Root of your project.

 
Old October 29th, 2005, 03:13 AM
Authorized User
 
Join Date: Oct 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to richie86
Default

There is some error when using the "\" in the URL, but if change with "/" it show no problem.
By the way, mind to be my friend? What kind of instant messaging that you are current using? I am using MSN. my MSN is [email protected]

 
Old October 29th, 2005, 05:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When you use a back-slash in a C# string it will not always be considered as a back-slash. The back-slash has special meaning as in many other programming languages; e.g. if you write \n it means new line. Perhaps this will help...

http://www.google.dk/search?hl=en&q=...e+character%22

Anyways, you can do it in three ways...

1. The first way is probably the most elegant way to do it. You can put an 'at' in front of a string and the C# compiler will ignore the escape character ('\') in the string.
Code:
Response.Redirect(@"somefolder\nice.aspx");
Notice that the first letter after the back-slash is 'n' which would normally render a new line.

2. The second way is the older version; you use a back-slash to escape the back-slash. Simply replace all back-slashes with two.
Code:
Response.Redirect("somefolder\\nice.aspx");
3. The third way is a little bit political. When developing applications for Windows it is OK to use back-slash, but some would say that this is wrong. Forward slash will AFAIK work on Windows and it will also work on Linux.
Code:
Response.Redirect("somefolder/nice.aspx");
This issue is causing some portability issues; i.e. if you are using back-slash in paths you will not be able to run the application - possibly web application - on Linux.

Hope it helps,
Jacob.
 
Old October 29th, 2005, 11:59 AM
Authorized User
 
Join Date: Oct 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to richie86
Default

oh yea, i forgot this is same as C++, the \\ consider as \, as well as the %% also will become %






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to link my button to a URL? larry Flash (all versions) 1 June 26th, 2007 01:00 AM
Link Button deontae45 ASP.NET 1.0 and 1.1 Basics 2 June 23rd, 2007 04:46 PM
Link Button sohrabus ASP.NET 2.0 Professional 1 November 14th, 2006 08:33 AM
Link Button sohrabus ASP.NET 1.0 and 1.1 Professional 3 October 27th, 2006 07:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.