[Bug] MyExtensions Behaving Differently When Used From Query

Hello. I've been having some trouble trying to get (a little too) fancy, but it would be really nice if I could get this working.

I've been trying to make a ModalDumpContainer using the modal dialog from bootstrap and I'm getting some particularly strange behavior. If you look at this gist the void Main in both MyExtensions and Broken are identical, but I get different results from each.

When running from MyExtensions directly I get the desired behavior (in both LINQPad 5 and 6), which is a set of Hyperlinqs that dump to a closable modal div. When I run the same void Main from a separate query consuming the ModalDumpContainer defined in MyExtensions it no longer works. I get different results between LINQPad 5 and 6 (I need it most in 5 right now, since I'm using it with Team Foundation Server libraries that only work on .NET Framework), but it doesn't work as expected in either. In 5 the "Show Modal Content" seems to work okay, but none of the "Multiply" nested links work. In 6 the CSS doesn't appear to load at all.

I've tried a bunch of approaches of trying to get scripts and styles into the page. At this point, some of it is a bit of a mess from experimenting with a bunch of different approaches, but the current state is the most functional I've managed to get it to operate so far.

Ideally it would be really nice if there was a safe way to register script, style, and link tags in the head tag in a way that works easily and consistently.


  • Ideally it would be really nice if there was a safe way to register script, style, and link tags in the head tag in a way that works easily and consistently.

    Yes, fair point. I'll add something shortly.

  • Try the new LINQPad 6 beta - it has new features to emit styles and scripts. Go to Help | What's New for info.

    Let me know how you get along.

  • When using AddScript I was getting an IE JavaScript error popup dialog saying it expected a } (even though the script had it) about every other execution? Once I moved the script to a file and included it by URI that solved my problem and it's working great for me now. Thanks so much! The Util.InvokeScript really simplified my need for a Hyperlinq that executed both .NET Code and JS too.

    Any chance I could get you to add this to LP5? I use both, but for the query I most want to use this functionality right now I'm stuck with using libraries that depend on .NET 4.5 which don't have a .NET Standard or .NET Core alternative.

  • I managed to extract this into a separate query that reliably reproduces the curly brace error on the first 2 executions and then I have to "Cancel All Threads and Reset" to get it to occur again:

    Util.HtmlHead.AddScript(@"window.onerror = function(msg, url, line, col, error) {
       // Note that col & error are new to the HTML 5 spec and may not be 
       // supported in every browser.  It worked for me in Chrome.
       var extra = !col ? '' : '\ncolumn: ' + col;
       extra += !error ? '' : '\nerror: ' + error;
       // You can view the information in an alert to see things working like this:
       alert('Error: ' + msg + '\nurl: ' + url + '\nline: ' + line + extra);
       // TODO: Report this error via ajax so you can keep track
       //       of what pages have JS issues
       var suppressErrorAlert = true;
       // If you return true, then error alerts (like in older versions of 
       // Internet Explorer) will be suppressed.
       return suppressErrorAlert;
  • Thanks - I've identified the problem and will release a beta with a fix this weekend.

  • The updated beta is working great. I've updated the HTML output to use the Control class properly and have been cleaning things up. I've also made the modal support a stack-style of navigation which I find quite handy. Besides the modal dump stack I'm also working on getting CodeMirror (a very powerful syntax-highlighting script) to help me visualize search results with both syntax highlighting AND custom highlights (I currently display these separately; if you want syntax highlighting I use LINQPad's built in functionality and if you want to highlight search results I use an old extension of mine that applies styles with HorizontalRun). This all started as a fun side thing, but I honestly think they'll make a great impact to my day-to-day productivity.

    I see LINQPad 5 Beta has something similar I can work with now which I greatly appreciate. I'll be working to make that functional for my purposes next and once I've got them working maybe I can release some utilities that demonstrate how I'm using them.

    Thanks so much! :smile:

  • Terrific - I'm glad it's working well for you.

Sign In or Register to comment.