日期:2014-05-18  浏览次数:20542 次

点击按钮让所有控件Enable全为False(用javascript)
我在Asp.net的用户控件里,我想用javascript实现,当点击Button(btnSave)时,所有按钮的Enable都为False,试了多次都不行,但在不是用户控件的页面就行.就用
JScript code
document.getElementById("txtCode").disabled=true;
.但在用户控件就是不行.请大家帮看下...代码如下:
HTML code

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AcademyUC.ascx.cs" Inherits="manager_UserControl_AcademyUC" %>
<script language="javascript" type="text/javascript">
<!--

function btnAdd_onclick() 
{
    document.getElementById("txtCode").disabled=true;
}

// -->
</script>

<table width="658" height="180" border="1">
 <tr>
    <td colspan="4" bgcolor="lavender"><center>
        学院信息</center></td>
  </tr>
  <tr>
    <td colspan="4" style="height: 26px">
        &nbsp;
        <input id="btnAdd" style="position: relative" type="button" value="增加" language="javascript" onclick="return btnAdd_onclick()" />
        &nbsp;<asp:Button
            ID="btnModify" runat="server" Style="position: relative" Text="修改" />&nbsp;<asp:Button
                ID="btnDelete" runat="server" Style="position: relative" Text="删除" />
        <asp:Button ID="btnSave" runat="server" Style="position: relative" Text="保存" OnClick="btnSave_Click" />
        <asp:Button ID="btnCancel" runat="server" Style="position: relative" Text="取消" />
        </td>
  </tr>
  <tr>
    <td>&nbsp;编号:</td>
    <td>&nbsp;<asp:TextBox ID="txtCode" runat="server" Style="position: relative; left: 1px; top: -2px;" ></asp:TextBox></td>
      <td rowspan="2">
          备注:&nbsp;</td>
      <td rowspan="2">
          &nbsp;
          <asp:TextBox ID="txtRemarks" runat="server" Height="54px" Style="left: -5px; position: relative; top: 1px;"
              TextMode="MultiLine" Width="210px"></asp:TextBox></td>
  </tr>
  <tr>
    <td>&nbsp;名称:</td>
    <td>&nbsp;<asp:TextBox ID="txtName" runat="server" Style="position: relative; left: 2px; top: 0px;"></asp:TextBox>*</td>
  </tr>
  <tr>
    <td colspan="4" bgcolor="lavender"><center>
        &nbsp;</center></td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;<asp:GridView ID="GridView1" runat="server" Style="position: relative" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" AutoGenerateColumns="False" >
        <FooterStyle BackColor="White" ForeColor="#000066" />
        <RowStyle ForeColor="#000066" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" />
            <asp:BoundField DataField="AcademyCode" HeaderText="编号" />
            <asp:BoundField DataField="AcademyName" HeaderText="名称" />
            <asp:BoundField DataField="Remarks" HeaderText="备注" />