Reputation: 878
I am using Visual Studio 2012. It contains the following textbox:
<asp:TextBox ID="txtdate" runat="server" OnTextChanged="txtdate_TextChanged" AutoPostBack="true"></asp:TextBox>
<img src="../img/scw.gif" title='Click Here' alt='Click Here' onclick="scwShow(scwID('ContentPlaceHolder1_txtdate'),this); setcalender();" />
On clicking on the image a Calendar opens in which the user can select the date. Now if I enter the date manually by typing and then press the Enter key txtdate_TextChanged
method is called but the change has to be done using the Calender. So I want to know why and how the browser/server is able to detect that the change is being done by Javascript.
And is there any way I can call the txtdate_TextChanged
method in javascript.
Thanks in advance.
Upvotes: 0
Views: 930
Reputation: 833
As you are saying that you click on the image and not the textbox it means that the textbox was never in focus and javascript functions do not trigger server side functions if they are called along with the server side functions like
<asp:Button runat ="server" ID="btn" OnClick="btn_Click" OnClientClick="return check();" />
where in javascript function check() you do your validations and return true.
So you have to do this in javascript on the onclick eventof your Calender
__doPostBack("txt_sssn_dt", "TextChanged");
Upvotes: 2