[英]I can't figure out why my textbox isn't firing my OnClick c# function in asp.net
I'm new to asp.net and I can't figure out why my onClick function isn't firing. 我是asp.net的新手,我无法弄清楚为什么我的onClick函数没有触发。
Here is my aspx code: 这是我的aspx代码:
<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: 然后我有一个ac#函数,我需要在单击文本框时运行:
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.
您所要做的就是在javascript文件中编写任何内容并在客户端使用它。 To do this, you can dothe following steps:
为此,您可以执行以下步骤:
In your aspx page inside the <head></head>
tag include 在
<head></head>
标签内的aspx页面中包括
<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). 在你的javascript文件中写一个函数来做任何你想做的事情(显示日历)。
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! 事件未触发,因为文本框没有服务器端onClick事件! Try to wire the event up on the client side!
尝试在客户端连接事件!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.