How to debug Javascript registered with RegisterClientScriptBlock method

I have many existing scripts that I need to debug, all of them are embedded in the code behind.

I would prefer to use the debbging functions on the client side of Visual Studio 2008, but breakpoints can only be set inside an aspx file using a script block.

The problem is that I cannot put a breakpoint on the scripts because they are all registered from the code behind the file (not the aspx file). Scripts are added to the page using the ClientScriptManager.RegisterClientScriptBlock method (Type, String, String, Logical)

Here is an example (it did not break, just an example of how it was added to the page).

if (!cs.IsClientScriptBlockRegistered(cstype, csname2))
{
  StringBuilder cstext2 = new StringBuilder();
  cstext2.Append("<script type=\"text/javascript\"> function DoClick() {");
  cstext2.Append("Form1.Message.value='Text from client script.'} </");
  cstext2.Append("script>");
  cs.RegisterClientScriptBlock(cstype, csname2, cstext2.ToString(), false);
}

Is it possible to debug it without having to pull out every script on the test page?

:

+3
1

; . - :

 cstext2.Append("<script type=\"text/javascript\"> function DoClick() {debugger;");
 cstext2.Append("Form1.Message.value='Text from client script.'} </");
...

, IE :

- > -- > . , " Script ()" " Script (Internet Explorer) .

, DoClick, , IE VS, script.

, .

+4

Source: https://habr.com/ru/post/1762181/


All Articles