Sashko  Chehotsky
Sashko Chehotsky

Reputation: 408

The call stack contains only external code

I want that when I click on a other became visible. I'm do it using jQuery, but I'm not strong in it. I wrote script:

    <script type="text/javascript">
        $(document).ready(function () {
            $('.visiblePanel').on('click', function () {
                $('.invisiblePanel').toggle();
            });
        });
    </script>

The layout I have done through С#:

Panel visiblePanel = new Panel();
visiblePanel.Style.Add("background-color", "red");
visiblePanel.CssClass = "visiblePanel";
Panel invisiblePanel = new Panel();
invisiblePanel.CssClass = "invisiblePanel";

Of course, it didn't work. But also a get an error: enter image description here

Without script everything is fine. I tried to disable Just My Code and got that:

enter image description here Realy, I googled what to do, but without success. Could you help me?

P.S. On jsfiddle.net my script in working. http://jsfiddle.net/ZMxg8/

P.P.S: The problem isn't in script! What happened with VS?? What means "The call stack contains only external code"???

Upvotes: 7

Views: 8125

Answers (3)

Sashko  Chehotsky
Sashko Chehotsky

Reputation: 408

I've found the solution. Steve B was right. Error "The call stack contains only external code" informed me that the debugger can't debug JavaScript code. And "mscorlib.pdb not loaded" was because when I tried to fix first error, I disabled something in options.=) Thank everybody for helping.

Upvotes: 1

Nitin Chaurasia
Nitin Chaurasia

Reputation: 263

Try this code:

 $(document).ready(function () {
        $('.visiblePanel').click(function () {
            $('.invisiblePanel').toggle();
        });
    });

C# Code

        Panel visiblePanel = new Panel();
        visiblePanel.Style.Add("background-color", "red");
        visiblePanel.CssClass = "visiblePanel";
        visiblePanel.Width = 10;
        visiblePanel.Height = 10;
        this.Controls.Add(visiblePanel);
        Panel invisiblePanel = new Panel();
        invisiblePanel.Width = 10;
        invisiblePanel.Height = 10;
        invisiblePanel.CssClass = "invisiblePanel";
        invisiblePanel.Style.Add("background-color", "black");            
        this.Controls.Add(invisiblePanel);

Upvotes: 0

Steve B
Steve B

Reputation: 37700

Your code dynamically generates Panel but does not include them in the Control tree.

Update your code like this:

Panel visiblePanel = new Panel();
visiblePanel.Style.Add("background-color", "red");
visiblePanel.CssClass = "visiblePanel";
this.Controls.Add(visiblePanel);

Panel invisiblePanel = new Panel();
invisiblePanel.CssClass = "invisiblePanel";    
this.Controls.Add(visiblePanel);

This should solve the issue.

However, I suggest you to declare this Panels in the aspx markup. This will be easier to maintain.

Upvotes: 3

Related Questions