0

我有 2 个单选按钮,如下所示:

<asp:RadioButton runat="server" GroupName="ebrochType" Text="Select Type 1" TextAlign="Right" ID="rbtSelect1" OnCheckedChanged="sel1" AutoPostBack="true" />

<asp:RadioButton runat="server" GroupName="ebrochType" Text="Select Type 2" TextAlign="Right" ID="rbtSelect2" OnCheckedChanged="sel2" AutoPostBack="true"  />

When one of these is selected, I need to open a page in a new window with no menubar etc...

这可能在后面的代码中吗?

我试过了,但没有用(它只是刷新了页面/更新面板):

Sub sel1(sender As Object, e As EventArgs)

    Page.ClientScript.RegisterStartupScript(Me.GetType(), "select1", "window.open('http://www.google.co.uk','','')", True)

End Sub
4

2 回答 2

0

是的,您可以通过使用键“onclick”和值“javascript:window.open('your url',your parameters)”为每个单选按钮添加一个属性,从后面的代码中做到这一点。

于 2011-07-19T09:45:14.383 回答
0

做到这一点的“现代”方法是使用 JQuery:

<div>
    <h3>Individual Radiobuttons</h3>
    <asp:RadioButton runat="server" ID="rb1" Text="Apples" CssClass="rb" GroupName="individ" />
    <asp:RadioButton runat="server" ID="rb2" Text="Oranges" CssClass="rb" GroupName="individ" />
    <asp:RadioButton runat="server" ID="rb3" Text="Bananas" CssClass="rb" GroupName="individ" />
</div>


<div>
    <h3>RadiobuttonList</h3>

    <asp:RadioButtonList runat="server" ID="rbList1" CssClass="rbList1" >
        <asp:ListItem Text="Cats" Value="1" ></asp:ListItem>
        <asp:ListItem Text="Dogs" Value="2"></asp:ListItem>
        <asp:ListItem Text="Rabbits" Value="3"></asp:ListItem>
    </asp:RadioButtonList>
</div>

使用外部 Javascript 文件:
<script type='text/javascript' language='Javascript' src="/path/to/jscript/Tom.js'></script>

  1. 在您的 JQuery 文件中,您为 onclick 或 onchange 事件定义一个事件处理程序。

    $(文档).ready(函数 () {

    $(".rb").change(function () {
        window.open('http://www.google.com/search?hl=en&btnG=Search&q=' + $(this).text());
    });
    
    $(".rbList1").change(function () {
        //With RadiobuttonLists, the JQuery is a little more convoluted - a glance
        //at the markup will reveal why.
        window.open('http://www.google.com/search?hl=en&btnG=Search&q=' + $('.rbList1 :checked').next().text(), 'WindowFromRadiobuttonList', 'width=300,height=600');
    
    });
    

    });

HTH。

于 2011-08-19T09:17:22.653 回答