asp.netvisual-studio-2010debuggingvisual-studio-expresswatch-window

Accessing javascript from watch window in visual studio?


I'm missing the ability to do 'document.getElementbyId('foo')' and evaluate it or get a list of all the methods etc. when setting a break point in the code behind.

Is this possible to get it from the watch window? (when I type 'document' in the watch window it says:"The name 'document' does not exist in the current context")


Solution

  • After reading Simon Wang's comment, an idea came into my mind:

    In the .aspx file I write:

    <asp:Literal Text="" ID="activate_debugger" runat="server"></asp:Literal>
    

    In the code-behind, instead of setting a break point, before the line I would usually create a breakpoing I write:

    activate_debugger.Text = "<script type='text/javascript'>debugger;</script>";
    

    now I can open the watch window and write document.getElementById('foo');