ASP.NET

How do i capture when a user clicks out of a text box for some reason the only time textchange fires up is when I hit the enter key?? Any idea!!
LVL 1
DRSLTAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

UnexplainedWaysCommented:
<html>
<head>
<script language=javascript>

      function DoThat()
      {
            alert("stuff");
      }

</script>
</head>
<body>

      <input type=text onchange=DoThat()>

</body>
</html>


UnexplainedWaysCommented:
Problem is it only works when you click in it, and then modify it, however the event is only called when you leave the box and not after every click.

Also, i know you asked for asp.net, however all you need to add is the javascript.  Server side code wont work for this.  
UnexplainedWaysCommented:
And back to the point of the question:

"the only time textchange fires up is when I hit the enter key??",

I'm thinking because asp.net is server side code.  The only time it can do something is when the user posts back.  So the only time it can check to see if the text is changed is when the submit button is clicked.  If you want something to happen client side you need javascript, and the first post will solve that.
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

UnexplainedWaysCommented:
Just played with it a bit more, and if you use 'onBlur' instead of 'onchange' in the example i showed, it should do the trick.

(If there was an edit button i would use it, dam these multiple posts)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DRSLTAuthor Commented:
How do you call an already exsiting function from the java script? I have a function call ..._TextChanged and it is in the aspx page i want to have the java script call it whenever it gets inside the above function?


Thanks,
UnexplainedWaysCommented:
"I have a function call ..._TextChanged and it is in the aspx page"

If you have something in the aspx page, then you will require the whole page to be submitted.





<html>
<head>
<script language=javascript>

      function AlertSoUKnow()
      {
            alert("Page has been reloaded");
      }


      function DoThat()
      {
            element = document.getElementById("theForm");
            theForm.submit();

      }

</script>
</head>
<body onload=AlertSoUKnow()>
<form id=theForm>

      <input type=text value=DoThat onBlur=DoThat()>
</form>

</body>
</html>




And then in your aspx_page, my guess is that you would need to say

if(textbox changed)
{
  call ..._TextChanged
}




How to do "textbox changed" i'm not quite sure because i haven't done it, but here's a few ideas:

1) Have a hidden field, that is set to true or false.  The defaul is false, during the DoThat() function, change it to true, so when the page is submitted, you check the hidden field to see if it has changed.

2) Have the previous value stored and then compare the 2, different then call the function.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.