RegisterStartupScript does not work after upgrading to 3.5

I am trying to upgrade asp.net C # web project from framework 2.0 to 3.5.

When I do this, the client side of the script that is written using RegisterStartupScript does not appear on the client page.

This works fine when I compile for 2.0 and 3.0, but not when I compile for 3.5.

Here is the code that fails:

Page myPage = (Page)HttpContext.Current.Handler;
ScriptManager.RegisterStartupScript(myPage, myPage.GetType(), "alertscript", "alert('test');", true);

This is called from a class project, not the web project itself, so I use HttpContext.Current.Handler.

There are no errors from the compiler, the CLR, and there are no JavaScript errors on the client side.

If I do an alertcript search on my displayed page, the above code does not actually exist.

Anyone have any ideas on what is going on?

-Edit -

, , script .

- ( ), . , , .

ScriptManager.RegisterStartupScript, - -?

-Edit2 -

, :

  • script -
  • script
  • script -

, , : myPage.ClientScript._registeredClientStartupScripts -, , , . , , .

, , , , -, .

, 2.0 3.0, 3.5.

+3
2

.

- Framework 3.5, dll System.Web.Extensions ​​ 3.5.

--, , , .

dll 2.0, 3.5.

, 3.5.

+1

1- ,

ScriptManager.RegisterStartupScript(myPage, myPage.GetType(), "alertscript", "alert('test');", true); 

- , script, , script.

2- UpdatePanel?
http://msdn.microsoft.com/en-us/library/bb359558.aspx

script, , , , , UpdatePanel,

+1

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


All Articles