如何调用TextBox WebForm控件的TextChanged [英] How to call TextChanged of TextBox WebForm Control
本文介绍了如何调用TextBox WebForm控件的TextChanged的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用配置为Bootstrap Datetimepicker
的TextBox
WebForm控件.
我需要启动服务器端TextChanged
事件.
我拥有的代码无法正常工作,因此不会调用服务器端部分.
I use TextBox
WebForm Control configured like a Bootstrap Datetimepicker
.
And I need to initiate server side TextChanged
event.
The code I have does not work so it does not call server side part.
HTML
<div class='datepicker input-group date' id='datetimepickerStart'>
<asp:TextBox ID="StartDate" class="form-control dateField" placeholder="Fecha" required runat="server" OnTextChanged="StartDate_TextChanged"></asp:TextBox>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
C#
protected void StartDate_TextChanged(object sender, EventArgs e)
{
// It does not fire :(
}
我试图强迫这样的事件,但没有欢乐.
I try to force this event like this but no joy.
JS
$('#datetimepickerStart').datetimepicker();
$('#datetimepickerStart').datetimepicker().on('dp.change', function (event) {
console.log(event.date);
$('#StartDate').change(); // It does not help
$('#StartDate').html(event.date); // It does not help
});
任何提示如何解决?
推荐答案
解决方案是添加ApiController并通过JQuery消耗我需要的东西.
Solution is to add ApiController and consume via JQuery what I need.
https://blogs.msdn.microsoft.com/henrikn/2012/02/23/using-asp-net-web-api-with-asp-net-web-forms/
这篇关于如何调用TextBox WebForm控件的TextChanged的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文