<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;"/>