Click here to Skip to main content
15,914,397 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i have one link button in my page.i want to redirect to a new page when mouse left button is clicked(new page should be loaded in same page);
but new page should be loaded in new window when i clicked on "open link in new window" from right button menu.

i have one link button "LinkButton1" and a text box "TextBox1"
my code is:
C#
protected void LinkButton1_Click(object sender, EventArgs e)
    {
        if(TextBox1.Text=="")
        {
            Response.Write("Enter content");
        }
        else
        {
            Response.Redirect("Page2.aspx");
        }

}

That is i want to redirect to a page if the text is not empty.it is working properly in click event.
now i want to execute same code when i clicked mouse right button and selected option "open link in new window" .how can i do it
Posted
Updated 31-Jan-10 22:28pm

This is default behaviour of the Link button, so no need to add any aditional code.

<asp:LinkButton runat="server" Text="Default Page" PostBackUrl="~/Default.aspx"></asp:LinkButton>
 
Share this answer
 
Try following code:

<a href="Default.aspx">Default</a>
 
Share this answer
 
1 - don't post 'answers' that are comments, edit your post
2 - what does

hi..thanks for your reply..but it wont work

mean ? It DOES work, there is no other way for it TO work, but if you think otherwise, you need to tell us what you do, what DOES happen, and post some code ( although there's only one way to create a link in HTML, you could be using a linkbutton, which would change things considerably )
 
Share this answer
 

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