私は中にいる...
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 は、「コード「Page.Clientscript」を参照する非静的フィールド、メソッド、またはプロパティ「System.Web.UI.Page.ClientScript.get」にはオブジェクト参照が必要です」と言っています。