我有这个UpdatePanel
:
<asp:TextBox ID="date" runat="server" />
<asp:ScriptManager ID="Manager" runat="server" />
<asp:UpdatePanel ID="setDate" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Label ID="checkRes" runat="server" /> <asp:Label ID="range" runat="server" />
<asp:ImageButton ID="check" runat="server" ImageUrl="../img/process.png" OnClick="check_Click" CausesValidation="false" UseSubmitBehavior="false"/>
<asp:Button ID="submit" runat="server" Text="Submit" CausesValidation="true" Enabled="false" />
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="setDate">
<ProgressTemplate>
<asp:Image ID="loader" runat="server" ImageUrl="~/img/loader.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="check" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<script type="text/javascript">
var textBox = document.getElementById('<% =date.ClientID %>');
var submitButton = document.getElementById('<% =submit.ClientID %>');
textBox.onchange = function () {
submitButton.disabled = true;
};
</script>
后面有这段代码:
protected void check_Click(object sender, EventArgs e)
{
submit.Enabled=true;
}
可以看到先Button
禁用,UpdatePanel
触发后会启用;现在我想要 if date
's text changedButton
变为禁用。我在这里测试了我的 JS,但它没有Button
在 ASPX 中禁用。