在鼠标右键,鼠标左键单击的同时重定向到另一页 [英] redirect to another page while mouse right, left click

查看:61
本文介绍了在鼠标右键,鼠标左键单击的同时重定向到另一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我的页面中有一个链接按钮.我想在单击鼠标左键时重定向到新页面(新页面应在同一页面中加载);
但是当我从右键菜单中单击在新窗口中打开链接"时,应该在新窗口中加载新页面.

我有一个链接按钮"LinkBut​​ton1"和一个文本框"TextBox1"
我的代码是:

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:

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

推荐答案

这是默认行为链接按钮,因此无需添加任何附加代码.

<asp:LinkButton runat="server" Text="Default Page" PostBackUrl="~/Default.aspx"></asp:LinkButton>
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>


尝试以下代码:

Try following code:

<a href="Default.aspx">Default</a>


1-不要发布评论的答案",请编辑您的帖子
2-
是什么
嗨..谢谢您的回复..但是它不起作用

意思是 ?它确实起作用,没有其他方法可以起作用,但是如果您认为不是这样,则需要告诉我们您所做的事情,发生的事情并发布一些代码(尽管只有一种方法可以创建链接)在HTML中,您可能正在使用链接按钮,这将使事情发生很大变化)
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 )


这篇关于在鼠标右键,鼠标左键单击的同时重定向到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆