Debuging Java script

  1. #1

    Debuging Java script

    Please can you explain me what I have to do in order not to get all Java script in one line (horizontally), like in attachment. I would like to have possibility to debug where java script lines are like in editor.

    Thanks
    Attached Thumbnails debuging.PNG  
  2. #2
    Hello,

    This is the default behavior of resource manager to make transferred data smaller. While this is a hell debugging, it's faster for users to load. Okay, this you already knew. Now, to the point:

    Set the resourceManager on your page to format the source. Useful as well -- when you are debugging -- is to set the rest of the scripts formatted as well.
    <ext:ResourceManager ID="ResourceManager1" runat="server" ScriptMode="Debug" SourceFormatting="true" />
    ScriptMode nicely formats -- and allow your visual studio to actually open -- the dynamic handles without giving you headaches. The ext.axd?v=... handles.

    SourceFormatting makes the actual source of what you've written using Ext.NET shows nicely as equivalent ExtJS-formated code.

    I hope this helps you debug your app.
    Last edited by fabricio.murta; Jan 25, 2015 at 5:14 PM.
  3. #3
    Hello Avenger
    Thanks for your support. Unfortunately this did not help. Maybe it's because I am using MVC. I tried also something like this:
    @{
        ViewBag.Title = "Index";
        Layout = "~/Views/Shared/_BaseLayout.cshtml";
        var X = Html.X();
        MvcResourceManager.RegisterGlobalScript(Url.Content("~/Scripts/GridScripts.js"));
        ResourceManager.GetInstance().ID = "resourcemanager1";
        ResourceManager.GetInstance().ScriptMode = Ext.Net.ScriptMode.Debug;
        ResourceManager.GetInstance().SourceFormatting = true;
    }
    but then I got:

    Server Error in '/' Application.
    
    Object reference not set to an instance of an object. 
      Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
     Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
    
    Source Error: 
    
    
    
    Line 6:      var X = Html.X();
    Line 7:      MvcResourceManager.RegisterGlobalScript(Url.Content("~/Scripts/GridScripts.js"));
    Line 8:      ResourceManager.GetInstance().ID = "resourcemanager1";
    Line 9:      ResourceManager.GetInstance().ScriptMode = Ext.Net.ScriptMode.Debug;
    Line 10:     ResourceManager.GetInstance().SourceFormatting = true
    with line 8 in red.
    Last edited by geoffrey.mcgill; Jan 26, 2015 at 3:27 PM.
  4. #4
    The same options you have on markup/code behind should be on razor syntax as well. For instance:
    @(Html.X().ResourceManager().ScriptMode(Ext.Net.ScriptMode.Debug).SourceFormatting(true))
    Did you try this?
  5. #5
    I put that line on the beginning of each view and partial view in my project, but still without success :(. Java script still appears in one horizontal line while debugging. Strange enough in some other test projects java script appears normal even without putting this line...
  6. #6
    Hmmm then maybe the only option left is if you provide us with a simple view+controller code that reproduces your issue, and then I review it until I see the generated javascript all ungolfed.

    You think it is reasonable to ask you for such a sample? (the shorter you make it, the better)
    Fabrício Murta
    Developer & Support Expert
  7. #7
    Hmmm it's too much effort for this kind of nuisance. I mean debugging works, only it is hard to follow it since everything is in one line. Maybe when I have more time I will try to make sample, that you can investigate.
  8. #8
    Just let us know when you are at it.

    For me, sincerely, these settings on the resourceManager made both the linked code and generated javascript be readable. (by breaking lines on generated code).

    @Daniil just pointed me, I might have committed a mistake. While what I was focusing was the generated code after you just open the page. What you're looking at is returned code/script from a directMethod or something like it, right? What is the exact situation when you get such unformatted code?
    Last edited by fabricio.murta; Jan 28, 2015 at 10:56 AM.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Unable to get the panels in Ext Net 3.0 DLL in Java Script
    By mohan.bizbites in forum 3.x Premium Help
    Replies: 4
    Last Post: Dec 25, 2014, 3:37 PM
  2. [CLOSED] set value of CheckColumn in java script
    By elke.schreiber in forum 2.x Premium Help
    Replies: 2
    Last Post: Jun 03, 2014, 10:31 AM
  3. [CLOSED] java script error
    By elke.schreiber in forum 2.x Premium Help
    Replies: 11
    Last Post: May 13, 2013, 3:19 PM
  4. Replies: 0
    Last Post: Jun 15, 2012, 12:49 PM
  5. [CLOSED] [1.0] Java Script broken under IE
    By tdracz in forum 1.x Premium Help
    Replies: 2
    Last Post: May 06, 2010, 5:46 PM

Posting Permissions