在客户端单击时重新加载页面 asp.net 页面


<asp:Button ID="btnExpand" runat="server" CssClass="btn" Text="Expand" ToolTip="Expand text area to view all text"
            Enabled="true" OnClientClick="return false;"/>
<asp:Button ID="btnShrink" runat="server" CssClass="btn" Text="Shrink" ToolTip="Shrink text area to original size"
            Enabled="false" />
<script type="text/javascript">                     
    document.getElementById('<%= this.btnExpand.ClientID %>').addEventListener("click", function () {
        if (document.getElementById('<%= this.txtTextArea.ClientID %>').clientHeight < document.getElementById('<%= this.txtTextArea.ClientID %>').scrollHeight) {
            document.getElementById('<%= this.txtTextArea.ClientID %>').style.height = document.getElementById('<%= this.txtTextArea.ClientID %>').scrollHeight+ "px";
            document.getElementById('<%= this.btnShrink.ClientID %>').disabled = false;
            document.getElementById('<%= this.btnExpand.ClientID %>').disabled = true; 
        }
        return false;
    });
    document.getElementById('<%= this.btnShrink.ClientID %>').addEventListener("click", function () {
        document.getElementById('<%= this.txtTextArea.ClientID %>').style.height = '80px';
        document.getElementById('<%= this.btnShrink.ClientID %>').disabled = true;
        document.getElementById('<%= this.btnExpand.ClientID %>').disabled = false;
        return false;
    });

页面在IE中单击收缩按钮时正在重新加载,但在Chrome中工作正常

我冒昧地猜测你需要改变:

 <asp:Button ID="btnShrink" runat="server" CssClass="btn" Text="Shrink" 
 ToolTip="Shrink text area to original size" Enabled="false" />

自:

 <asp:Button ID="btnShrink" runat="server" CssClass="btn" Text="Shrink" 
ToolTip="Shrink text area to original size" Enabled="false" 
OnClientClick="return false;" />

编辑:

尝试将标记更改为以下内容:

<input type="button" runat="server" class="btn" title="Shrink text area to original size" onclick="return false;"/>

最新更新