【发布时间】:2017-07-04 06:37:01
【问题描述】:
我想用 C# 在 asp.net 中的静态方法服务器端代码中执行 JavaScript 警报。我尝试了很多方法,但都不起作用。
例如,我尝试过
[WebMethod]
public static void EntrySave(string schoolName)
{
Response.Write("<script>alert('Hello');</script>");
}
和
[WebMethod]
public static void EntrySave(string schoolName)
{
ScriptManager.RegisterStartupScript(this, GetType(), "showalert",
"alert('Only alert Message');", true);
}
还有更多。但它没有在 webstatic 方法中显示警报。
【问题讨论】:
-
你是如何/从哪里调用静态方法的?
-
我从客户端调用的 ajax 方法调用的这个静态方法。
-
请在[WebMethod]下方添加[ScriptMethod]并立即尝试。
-
我试过@HardikLeuwa 但没有用。
标签: javascript c# jquery asp.net