Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击java脚本上的asp.net单选按钮_Javascript_C#_Asp.net - Fatal编程技术网

Javascript 单击java脚本上的asp.net单选按钮

Javascript 单击java脚本上的asp.net单选按钮,javascript,c#,asp.net,Javascript,C#,Asp.net,在下面的代码中,我有一个html收音机和一个java脚本代码。检查收音机时,标签1文本的文本将更改为“测试”。 我的问题是,如何对运行在客户端的asp:radiobutton执行相同的操作 <input id="Radio1" checked="true" onmousedown="fun()" name="R1" type="radio" value="V1" /></p> <script> function fun() { docum

在下面的代码中,我有一个html收音机和一个java脚本代码。检查收音机时,标签1文本的文本将更改为“测试”。 我的问题是,如何对运行在客户端的asp:radiobutton执行相同的操作

 <input id="Radio1" checked="true" onmousedown="fun()" name="R1" type="radio"         
value="V1" /></p>
<script>
function fun()
{
 document.getElementById("Label1").innerHTML.text = "test";

}
</script>

函数fun() { document.getElementById(“Label1”).innerHTML.text=“test”; }
如果这是经典ASP,您可以使用:

<asp:RadioButtonList ID="RadioButtonList" runat="server" onclick="fun();">

            <asp:ListItem Text="JavaScript" Value="JavaScript</asp:ListItem>
            <asp:ListItem Text="C#" Value="C#"></asp:ListItem>
            <asp:ListItem Text="ASP.Net" Value="ASP.Net"></asp:ListItem>

</asp:RadioButtonList>


<script type='text/javascript'>

function fun()
{
 document.getElementById("Label1").innerHTML.text = "test";

}

</script>

如果这是经典ASP,您可以使用:

<asp:RadioButtonList ID="RadioButtonList" runat="server" onclick="fun();">

            <asp:ListItem Text="JavaScript" Value="JavaScript</asp:ListItem>
            <asp:ListItem Text="C#" Value="C#"></asp:ListItem>
            <asp:ListItem Text="ASP.Net" Value="ASP.Net"></asp:ListItem>

</asp:RadioButtonList>


<script type='text/javascript'>

function fun()
{
 document.getElementById("Label1").innerHTML.text = "test";

}

</script>

将ClientIDMode设置为“Static”,以便ID不会更改

<asp:RadioButton id="R1" ClientIDMode="Static" runat="server" onmousedown="fun()" Value = "V1"></asp:RadioButton>

我只知道如何使用Jquery来完成,所以您的脚本块看起来像这样

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script>       
    function fun() {
        $('label[for="R1"]').text('your new text');

    }
</script>

函数fun(){
$('label[for=“R1”]”)。文本(“您的新文本”);
}
将ClientIDMode设置为“Static”,以便ID不会更改

<asp:RadioButton id="R1" ClientIDMode="Static" runat="server" onmousedown="fun()" Value = "V1"></asp:RadioButton>

我只知道如何使用Jquery来完成,所以您的脚本块看起来像这样

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script>       
    function fun() {
        $('label[for="R1"]').text('your new text');

    }
</script>

函数fun(){
$('label[for=“R1”]”)。文本(“您的新文本”);
}

没有onmousedown事件mousedown事件是jquery事件处理程序,而不是webforms。没有onmousedown事件mousedown事件是jquery事件处理程序,而不是webforms。