I'm new to asp.net and I can't figure out why my onClick function isn't firing.
Here is my aspx code:
<asp:TextBox ID="TextBox1" runat="server" OnClick="TextBox1_OnClick"></asp:TextBox>
I then have ac# function that I need to run when the textbox is clicked:
protected void TextBox1_OnClick(object sender, EventArgs e)
{
//do stuff
}
You should really consider using client side coding for this scenario. why do you have to go to the server to display a calender on click of a text box. All you have to do is write whatever is to be done in a javascript file and use it in client side. To do this, you can dothe following steps:
In your aspx page inside the <head></head>
tag include
<script type="text/javascript" language="javascript" src="YourJavaScriptFile.js"></script>
In your javascript file write a function to do whatever you want (display the calender).
I am not giving you the code as such because
Enjoy coding.
The event is not firing because there is no server side onClick event for textbox! Try to wire the event up on the client side!
I'd suggest to go for Ajaxtoolkit calendar control. Have a look at demo here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.