Reputation: 971
I have a button that I want to open a calendar and then disappear until a calendar date is selected. The calendar is legacy code in ASP classic and updates a textbox on my ASP.NET form when the user picks a date via JavaScript. I already have everything working except the disappear/reappear of the button.
Button:
<asp:Button ID="AddToCartButton" runat="server" Text="Reserve" OnClick="AddToCartButton_Click" />
TextBox:
<asp:TextBox ID="ReservationDate" style="padding-left:10px;" runat="server" AutoPostBack="true" ReadOnly="false" visible="true" CssClass="BlankTextBox" Columns="25" OnTextChanged="ReservationDateSelected"/>
The button opens a calendar, passing the identity of the textbox so the calendar can put the chosen date in it via JS. I want the button to disappear when clicked, which I can do with button.visible = false, but the TextBox obviously does not respond to OnTextChanged when JS fills it.
How can I make set button.visible = true when the calendar uses JS to fill the textbox?
Thanks!
Upvotes: 1
Views: 695
Reputation: 30162
Use the
onchangeevent right inline - this isn't known by asp.net and will be rendered out and called via javascript. Set your button visibility in that procedure
See:
Upvotes: 1
Reputation: 21112
Add this in your js where appropriate:
<asp:Button ID="AddToCartButton" onclientclick="this.display='none';"
runat="server" Text="Reserve" OnClick="AddToCartButton_Click" />
//show after calender click
document.getElementById('<% = AddToCartButton.ClientID').display = 'block';
Upvotes: 1