如何在列表框中打开网页地址 [英] how do i open web page address in listbox

查看:100
本文介绍了如何在列表框中打开网页地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框,列表框和两个按钮.

当我单击button1时,我们输入的网址将移动到列表框.
为此,只需在列表框中添加多个网址即可.
现在,当我单击第二个按钮时,列表框中的地址会在多个新窗口中打开.
我的代码是

i m having one text box,list box and two button.

when i click button1 the webaddress which we entered is moved to listbox.
like that by adding more than one webaddress to list box.
now when i click second button the address in list box open in multiple new window.
my code is

<table>
  <tr>
  <td>
  <asp:TextBox ID="txtMail" runat="server"></asp:TextBox>
  </td>
  <td>
  <asp:ListBox ID="List" runat="server"></asp:ListBox>
  <a href="Default.aspx" runat="server"></a>
  </td>
  </tr>
  <tr>
  <td colspan="2" align="center">
      <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
  <asp:Button ID="btnClick" Text="Click" runat="server" onclick="btnClick_Click" />
  </td>
  </tr>
  </table>





在后面的代码中





in code behind

protected void Button1_Click(object sender, EventArgs e)
    {
        List.Items.Add(txtMail.Text);

    }





protected void btnClick_Click(object sender, EventArgs e)
    {
what can i do here
    }



通过使用javascript手段,告诉我代码



by using javascript means tell me the code

推荐答案

使用anchor标签的target属性可以实现以下目的:

Use the target attribute of the anchor tag to achieve that:

<a target="_blank" href="http://www.google.com">Go and google it!</a>



这就是全部!

问候,

-MRB



That''s all there is to it!

Regards,

-MRB


我不确定您的问题,但这是我的解决方法

I am not sure about your question, but here is my solution

//Javascript
<script>
    function openItem(ctrl)
    {
        window.open(ctrl.value);
    }
</script>
//ASPX
 <asp:listbox id="ListBox1" runat="server" onclick="openWebSite(this)" xmlns:asp="#unknown">
            <asp:listitem text="http://www.google.com"></asp:listitem>
            <asp:listitem text="http://www.yahoo.com"></asp:listitem>
        </asp:listbox>


这篇关于如何在列表框中打开网页地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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