0

I have the following scenario.

UpdatePanel GridView EditMode Shows UserControl with JQuery code

Inside that usercontrol I can't see the fields from JQuery. If I remove the update panel everything works fine. Most examples I've found don't seem to have a usercontrol inside the update panel. I'm not sure if that makes a difference or not. I tried using the ScriptManager.RegisterClientScriptBlock but I may have had it in the wrong place.

This worked for me, the example didn't use wildcards though, that did the trick. Since I had the control on datarows, each one had a different ID.

 function BindEvents() {
        $(document).ready(function () {
            $("[id*='txtBox']").on("mouseover",function () {
                $(this).val("DOn't leave");
                var other = 0;
            });
        });
    }
Community
  • 1
  • 1
Jason
  • 367
  • 6
  • 18
  • Why can't you see the fields from jQuery? What is stopping you? – Malk Aug 20 '14 at 22:43
  • I don't know, that's my question. I figured since the JQUery was inside the usercontrol it would be ok, but the events don't seem to fire. I'm trying to use focusin and focusout. I don't get any debug errors either. – Jason Aug 20 '14 at 22:46
  • You mean the script tag to include the jquery library is in the user control? – Malk Aug 20 '14 at 22:47
  • Sorry, no, just the JQuery code, the script tag is in the parent file. Is that a problem? – Jason Aug 20 '14 at 22:48
  • Dou you have `$( document ).ready()` inside the update panel? If so this won't work. If you think about it, it makes sense, `$( document ).ready()` fires when the doument is ready, it won't fire again when the update panel, err, updates. – Jon P Aug 20 '14 at 23:20
  • No, I thought about putting it inside the usercontrol though. I'm trying to write a quick example at home. – Jason Aug 20 '14 at 23:25
  • Aslo inspect the HTML rendered to the page/update panel (use dev tool in Chrome or Firebug for Firefox) and check for ID mangling if you're using ID's for your jQuery hooks. – Jon P Aug 20 '14 at 23:29
  • Ok I see the same thing here, it seems to be the event binding like I've read about. But where should I put the scriptmanager – Jason Aug 20 '14 at 23:47
  • Check if this [SO] (http://stackoverflow.com/questions/256195/jquery-document-ready-and-updatepanels) resolves your issue... – rfernandes Aug 21 '14 at 00:12
  • This works at home, I tried it at work, I'll have to try it again tomorrow. The trick is to use wildcards I'll post it above. http://stackoverflow.com/questions/256195/jquery-document-ready-and-updatepanels – Jason Aug 21 '14 at 00:14

1 Answers1

0

This worked for me, the example didn't use wildcards though, that did the trick. Since I had the control on datarows, each one had a different ID.

Community
  • 1
  • 1
Jason
  • 367
  • 6
  • 18