normality2000
normality2000

Reputation: 51

Detect Textbox Change Using JQuery

Using VS2012 to create a web application in VB, I have the following issue:

I create a asp:CalendarExtender that populates a asp:TextBox. This Textbox has the property Enabled="False" assigned to it. Once the asp:CalendarExtender has been called it will place a date in the TextBox in the format 'Sept 1 2000'.

I now want to use JQuery to detect this change. I have come across many examples which rely on a text change using the keyboard or a Blur, but none of these work. I have even attached a JQuery event to the button that triggers the Calendar to pop-up that removes the 'Enabled=False' property of the asp:TextBox [My train of thought was to remove the enabled property, allow the JQuery to detect a pasted change, then disable the textbox again]

Any ideas or suggestions gratefully received.

Upvotes: 0

Views: 858

Answers (1)

timbck2
timbck2

Reputation: 1066

Do you need Enabled="False" on the TextBox, or would ReadOnly="True" suffice? Because the CalendarExtender will not pop up when you click the TextBox if the TextBox isn't enabled.

You could do something like this:

<script type="text/javascript">
  function alertChanged() {
    alert("Text changed.");
  }
</script>

With:

<asp:TextBox ID="tbxCalTest" runat="server" ReadOnly="true"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="calendarTest" runat="server" TargetControlID="tbxCalTest"
  OnClientDateSelectionChanged="alertChanged"></ajaxToolkit:CalendarExtender>

Upvotes: 1

Related Questions