0

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.

1

1 Answer 1

2

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");

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.