Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Call Change() function
Message
Information générale
Forum:
Javascript
Catégorie:
JQuery
Divers
Thread ID:
01612951
Message ID:
01612964
Vues:
53
You should check what the name of that form field really is. If you're using Web Forms and the control is in a container, it'll by something like Ctl1_txtMyTextBox or something along those lines.

Use your DevTools of choice and Inspect Element to find out what hte real ID is then use that name instead.
$("#Ctl1_txtMyTextBox").change(...);
FWIW, in the past I've used a function that helps me with this:
$$ = function (id, context) {
        /// <summary>
        /// Searches for an ID based on ASP.NET naming container syntax.
        /// First search by ID as is, then uses attribute based lookup.
        /// Works only on single elements - not list items in enumerated
        /// containers.
        /// </summary>    
        /// <param name="id" type="var">Element ID to look up</param>    
        /// <param name="context" type="var">
        /// </param>    
        /// <returns type="" /> 
        var el = $("#" + id, context);
        if (el.length < 1)
            el = $("[id$=_" + id + "],[id*=" + id + "_]", context);
        return el;
    };
You can then use it like this:
$$("txtMyTextBox").change(function() { alert('exit') });
and it'll find anything that matches this name regardless of the WebForms container prefixes.

+++ Rick ---

>I am trying to incorporate a jQuery Change function in an asp.net page that would make certain control invisible when user starts typing (making changes) in a text box. My initial test, just to call an alert() does not seem to work. Here is my code:
>
>
><script type="text/javascript">
>       $(document).ready(function () {
>
>           $("txtMyTextbox").change(function () {
>
>               alert("Change Function Called");
>
>           });
>
>   })
></script>
>
>
>What is wrong with my code? TIA
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform