重定向雅虎网站? [英] redirecting yahoo site?

查看:76
本文介绍了重定向雅虎网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框和一个按钮.
如果我输入www.yahoo.com之类的文本框并点击Button,我想重定向yahoo网站.
请帮我.

I have a textbox and a button.
If I type in the textbox like www.yahoo.com and hits on Button i would like to redirecting yahoo site.
Plz help me.
thnx in advance.

推荐答案

在该按钮的click事件中,使用Response.Redirect.

如果目标是重定向到另一个站点,那么进行服务器调用确实是浪费时间.使用JavaScript处理此问题会更直接.

In the click event of that button, use Response.Redirect.

If the objective is to redirect to another site then it is really a waste of time to make a server call. Handling this with JavaScript would be more direct.

window.location.href = document.GetElementById("txtbox").Value;
or
window.open(document.GetElementById("txtbox").Value);


代码在下面
code is below
private void Button_Click(object sender, EventArgs e) 
   {
      Response.Redirect("http://" + txtURL.Text);
   }

,但在执行重定向之前,请验证文本框中的URL.

删除了对ToString()的调用,因为它是多余的,并且浪费了处理器时间.为什么要在字符串上调用ToString?

but before perform redirection, validate the URL in textbox.

Removed the call to ToString() because it is redundant and a waste of processor time. Why would you call ToString on a string ?


这篇关于重定向雅虎网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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