<tr>
                      <td align="right" width="80">大分类:
                      </td>
                      <td width="180">
                          <asp:RadioButtonList ID="kind1" runat="server" RepeatColumns="0" RepeatDirection="Horizontal">
                          <asp:ListItem Value="收入" Text="收入"></asp:ListItem>
                          <asp:ListItem Value="支出" Text="支出"></asp:ListItem>
                          </asp:RadioButtonList>
                      </td>
                      <td rowspan="3" width="240"></td>
                  </tr>
                  <!--隐藏行-->
                  <tr id="qty" style="display:none">
                      <td align="right">预计月消费:
                      </td>
                      <td><asp:TextBox CssClass="textbox1" Width="170px" MaxLength="30" ID="mconsume" EnableViewState="False" runat="server" ToolTip="预计本月该小项的消费量,后续可更改"></asp:TextBox>
                      </td>
                  </tr>
当选择“支出”,隐藏行显示;选择“收入”,又隐藏,这要怎么实现呢
或者将textbox设为只读也行

解决方案 »

  1.   

    把RadioButtonList换成客户端单选按钮<head>
    <title></title>
    <script language="javascript">
    function hiddenRow()
    {
    document.getElementById("qty").style.visibility = "hidden";
    }function showRow()
    {
    document.getElementById("qty").style.visibility = "visible";
    }
    </script>
    </head><body>
    <tr>
    <td align="right" width="80">大分类:
    </td>
    <td width="180">
    <input type="radio" name="radiobutton" value="radiobutton" onclick="javascript:showRow()" />
      支出
    <input type="radio" name="radiobutton" value="radiobutton" onclick="javascript:hiddenRow()" />
      收入
     </td>
    <td rowspan="3" width="240"></td>
    </tr>
    <div id="qty">
    <!--隐藏行-->
    <tr style="display:none">
    <td align="right">预计月消费:
    </td>
    <td><asp:TextBox CssClass="textbox1" Width="170px" MaxLength="30" ID="mconsume" EnableViewState="False" runat="server" ToolTip="预计本月该小项的消费量,后续可更改"></asp:TextBox>
    </td>
    </tr>
    </div>
    </body>
    </html>
      

  2.   

    一定要在客户端吗,服务器端就不能处理?因为还有些其他的处理是在服务器端,所以如果把radio改成客户端的,这些处理又不行了
      

  3.   

    知道的,这处理应该很简单的吧,怎么就没人行行好呢,PLS
      

  4.   

    用Panel包括要隐藏和显示的部分,在服务器端控件Panel就可以了页面aspx代码<form id="Form1" method="post" runat="server">
    <table>
    <tr>
    <td align="right" width="80">大分类:
    </td>
    <td width="180">
    <asp:RadioButtonList ID="kind1" runat="server" RepeatColumns="0" RepeatDirection="Horizontal" AutoPostBack="True">
    <asp:ListItem Value="收入">收入</asp:ListItem>
    <asp:ListItem Value="支出">支出</asp:ListItem>
    </asp:RadioButtonList>
    </td>
    <td rowspan="3" width="240"></td>
    </tr>
    <asp:Panel id="Panel1" runat="server"> <!--隐藏行-->
    <TR>
    <TD align="right">预计月消费:
    </TD>
    <TD>
    <asp:TextBox id="mconsume" runat="server" ToolTip="预计本月该小项的消费量,后续可更改" EnableViewState="False"
    MaxLength="30" Width="170px" CssClass="textbox1"></asp:TextBox></TD>
    </TR>
    </asp:Panel>
    </table>
    </form>服务器端RadioButtonList的SelectedIndexChanged事件cs代码
    private void kind1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    if (this.kind1.SelectedValue.Trim() == "收入")
    this.Panel1.Visible = false;
    if (this.kind1.SelectedValue.Trim() == "支出")
    this.Panel1.Visible = true;
    }
      

  5.   

    这样行是行,谢谢了,
    不过有个问题,设置AutoPostBack="True",就会往服务器回传,这样有点讨厌
    我是想能不能给radiobuttonlist绑定一个js在客户端处理,据说radiobuttonlist上绑定js比较麻烦,不知道有什么方法