Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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
如何在asp.net中比较单选按钮值和文本框值_Asp.net_Visual Studio 2008 - Fatal编程技术网

如何在asp.net中比较单选按钮值和文本框值

如何在asp.net中比较单选按钮值和文本框值,asp.net,visual-studio-2008,Asp.net,Visual Studio 2008,我有四个单选按钮和一个文本框。我必须检查所选单选按钮值是否等于文本框值。。“任何人请帮助我”文本框不包含值属性 if (!string.IsNullOrEmpty(RadioButtonList1.SelectedValue) && RadioButtonList1.SelectedValue.Equals(TextBox1.Text, StringComparison.Ordinal)) { //your code goes here

我有四个单选按钮和一个文本框。我必须检查所选单选按钮值是否等于文本框值。。“任何人请帮助我”

文本框不包含值属性


if (!string.IsNullOrEmpty(RadioButtonList1.SelectedValue) &&
                RadioButtonList1.SelectedValue.Equals(TextBox1.Text, StringComparison.Ordinal))
    {
        //your code goes here
    }

好的。您没有说明要在哪里进行比较,即客户端还是服务器端。如果您希望在服务器端进行比较,您可以选择先前发布的答案,否则对于客户端,请使用Jquery尝试此答案

<div>
    <input type='radio' name='rd' value='A'>
    <input type='radio' name='rd' value='B'>
    <input type='radio' name='rd' value='C'>
    <br />
    <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</div>

<script type="text/javascript" >
    $(document).ready(function(){
    $("input:radio[name='rd']").click(function(){
        if($(this).is(":checked"))
        {
            if($.trim($(this).val()) == $.trim($("#txtName").val()))
                alert("Yeah!I got matched value.");
            else
                alert("Oops!Not matched.");
        }
    });

    });
</script>



您将不得不给我们更多的工作空间。。。
<div>
    <input type='radio' name='rd' value='A'>
    <input type='radio' name='rd' value='B'>
    <input type='radio' name='rd' value='C'>
    <br />
    <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</div>

<script type="text/javascript" >
    $(document).ready(function(){
    $("input:radio[name='rd']").click(function(){
        if($(this).is(":checked"))
        {
            if($.trim($(this).val()) == $.trim($("#txtName").val()))
                alert("Yeah!I got matched value.");
            else
                alert("Oops!Not matched.");
        }
    });

    });
</script>