Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP.NET

Posted on 2006-04-18
6
Medium Priority
?
243 Views
Last Modified: 2012-05-05
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!!
0
Comment
Question by:DRSLT
  • 5
6 Comments
 
LVL 12

Assisted Solution

by:UnexplainedWays
UnexplainedWays earned 2000 total points
ID: 16480461
<html>
<head>
<script language=javascript>

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

</script>
</head>
<body>

      <input type=text onchange=DoThat()>

</body>
</html>


0
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 16480491
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.  
0
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 16480518
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Accepted Solution

by:
UnexplainedWays earned 2000 total points
ID: 16480671
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)
0
 
LVL 1

Author Comment

by:DRSLT
ID: 16480676
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,
0
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 16483522
"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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question