call javascript code from code behind

  1. #1

    call javascript code from code behind

    I am trying to call javascript code in code behind (.aspx.cs) to reload a page like this:
    X.Js.AddScript("parent.EBodyPanel.activeTab.reload();");
    But its not working (no js error) , I tried with simpler alert function:
    X.Js.AddScript("alert('reload');");
    But still no luck. Am I missing something?
  2. #2
    Hello @atroul!

    I can say with confidence that, yes, you are missing something. But am left in the dark trying to help you figure out what that is, without knowing how you have your code behind trigger that command.

    For instance, if you have this on your Page_Load() code, in code behind:

    X.Js.AddScript("console.log('xAddJs');");
    X.AddScript("console.log('xAdd');");
    Both commands will be executed. In fact, X.AddScript() is but a shorthand to X.Js.AddScript() you don't need to X.Js, it was necessary in early Ext.NET versions but now you can make your call shorter and its not being used for a long time. Well, of course, if you like it X.Js, it is yours to choose. :)
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello Fabricio and thank you for your reply.
    Well I solved it by calling the javascript function in the Success event of button click and not in the "OnEvent" in code behind.
    I will open a new thread regarding another problem I have
  4. #4
    Hello @atroul!

    Well, it is not clear to me how it helped you but, anyway, I'm glad it did! :) Thanks for the feedback.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] How to call one procedure (code behinde) from javascript
    By joe2014 in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Sep 26, 2014, 3:17 PM
  2. [CLOSED] How can Xscript code call code behind method..need syntax
    By Poulami in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 13, 2014, 7:39 PM
  3. Replies: 4
    Last Post: Apr 11, 2014, 4:31 PM
  4. How to call the javascript function form code behind
    By harshad.jadhav in forum 1.x Help
    Replies: 3
    Last Post: Mar 29, 2011, 3:00 PM
  5. Replies: 6
    Last Post: Mar 11, 2011, 5:30 AM

Tags for this Thread

Posting Permissions