2010-12-22 59 views

回答

0

textBox不包含Value属性。


if (!string.IsNullOrEmpty(RadioButtonList1.SelectedValue) && 
       RadioButtonList1.SelectedValue.Equals(TextBox1.Text, StringComparison.Ordinal)) 
    { 
     //your code goes here 
    } 
2
if(radioButtonList.SelectedValue == textBox1.Text.Trim()) 
{ 
    //your code goes here 
} 
0

,你希望你希望它的服务器端,你可以喜欢早些时候公布的答案对,否则客户端尝试这一个使用jQuery做这种比较,即客户方或ServerSide.If Well.You没有澄清。

<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> 

点击此链接:

DEMO

相关问题