Javascript and PostBack on one TextBox

R

rockdale

Hi, All

I have a textbox for user to input SSN, I havea javascript to format
what he input to SSN format, I also have a onChange postback function
to retrieve other info based on the SSN.


<asp:TextBox id="txtSSN" runat="server" AutoPostBack="true"
onKeyDown="javascript:myJavaFunction"></asp:TextBox>

in code behind
protected void SSN_OnTextChanged(object sender, System.EventArgs e)
{
//do database query
}

The OnTextChanged event triggered correct if I do not have the
OnKeyDown Javascript. But if I put the onKeyDown javascript. then the
OnTextChanged event won't get triggered.

Can I put both JavaScript and postback function on one control? If so,
what I did wrong or is there another work around?

Thanks a lot
-Rockdale
 
E

Eliyahu Goldin

Try

onKeyDown="return myJavaFunction()"

and make myJavaFunction return true.

Eliyahu
 
R

rockdale

I am sorry. In my first post, onKeydown should be onKeyDown="return
myJavaFunction()".

If I remove protected void SSN_OnTextChanged() post back function, My
jjavascript function works fine. but not both.

Again, thanks
-Rockdale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top