我里面......如何从一个方法内部调用一个javascript函数?
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);
}
}
}
我拿到的RegisterStartupScript代码从MSDN的例子。很明显,我没有正确实施它。目前比较说:“非静态字段,方法或属性需要对象引用'System.Web.UI.Page.ClientScript.get'引用代码片段”Page.Clientscript;“谢谢。
你能告诉我更多关于你想做什么吗?你的建筑和这样的?你想在更高层次上共谋什么? – 2008-09-30 16:14:40
你是什么意思由DoSome()“触发一些JavaScript”? – 2008-09-30 17:25:06