我在里面...
public class bgchange : IMapServerDropDownBoxAction
{
void IServerAction.ServerAction(ToolbarItemInfo info)
{
Some code...
在“一些代码”之后我想触发
[WebMethod]
public static void DoSome()
{
}
这会触发一些 javascript。这可能吗?
好的,在这里切换方法。我能够调用 dosome(); 触发但没有触发javascript。我曾尝试使用 registerstartupscript 方法,但不完全了解如何实现它。这是我尝试过的:
public class bgchange : IMapServerDropDownBoxAction
{
void IServerAction.ServerAction(ToolbarItemInfo info)
{
...my C# code to perform on dropdown selection...
//now I want to trigger some javascript...
// Define the name and type of the client scripts on the page.
String csname1 = "PopupScript";
Type cstype = this.GetType();
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{
String cstext1 = "alert('Hello World');";
cs.RegisterStartupScript(cstype, csname1, cstext1, true);
}
}
}
我从一个 msdn 示例中获得了 registerstartupscript 代码。显然我没有正确实施它。目前 vs 说“非静态字段、方法或属性‘System.Web.UI.Page.ClientScript.get’需要对象引用,引用代码段“Page.Clientscript;”谢谢。