Click here to Skip to main content
15,881,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I have added a button in my asp.net page,

where i'm redirecting it to some other page... using server.transfer
but unfortunately its not working...

my code:

protected void btnAdd_Click(object sender, EventArgs e)
        {
            Server.Transfer("Newuser.aspx");
        }


plzzz help me.

thanks
Posted
Comments
Tom Marvolo Riddle 19-Apr-14 5:12am    
any errors?
Rahul VB 19-Apr-14 5:55am    
hey brother, i think he has not given the complete URL.
Tom Marvolo Riddle 19-Apr-14 5:57am    
i guess so :)
Rahul VB 19-Apr-14 5:58am    
OT- By the way, where are you? i mean holiday today? :)
Tom Marvolo Riddle 19-Apr-14 6:02am    
OT- Nope.I don't have holiday in saturdays.

1 solution

Hello brother,

I added an other page called :

Quote:
Default2.aspx


So on button click i will get redirected to Default2.aspx page:

C#
public void clickme(object sender, EventArgs e)
   {

       Server.Transfer(@"~\Default2.aspx");
   }

}


Please note the ~(tilde) and the @ symbol. Think of your project as a file system in UNIX. You need to traverse till that file so that you can access it.


Now i will tell you one more thing, add a link button to your web page:

XML
<asp:LinkButton ID="lb" Text="click" PostBackUrl="~/Default2.aspx" runat="server" />





Observer the
Quote:
PostBackUrl="~/Default2.aspx"

property.

Do you see the path it picks up automatically? if you try the above two codes, you will find that the results are same.

Just try both of them and let me know.

Thanks,
-Rahul
 
Share this answer
 
v6

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900