-1

これはアラートを開く私のコードです。私が欲しいのは、アラートが表示されている「OK」を押すと、メソッド/関数を呼び出すことができるということです。

ClientScriptManager CSM = Page.ClientScript;
string strScript = "<script>";
strScript += "alert('There is no Bookmarked Question Available');";
strScript += "  document.getElementById('btnReview').onclick=true";

strScript += "</script>";
ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", strScript, false);
4

5 に答える 5

0

私が正しく理解している場合は、コードを次のように変更する必要があります

ClientScriptManager CSM = Page.ClientScript;
    string strScript = "<script>";
    strScript += "alert('There is no Bookmarked Question Available');";
    strScript += "  document.getElementById('btnReview').onclick();";

    strScript += "</script>";
    ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", strScript, false);

この場合、alert 呼び出し onclick の後、呼び出しメソッド Display に対して、クライアント メソッドの場合、次のようになります。

ClientScriptManager CSM = Page.ClientScript;
    string strScript = "<script>";
    strScript += "alert('There is no Bookmarked Question Available');";
    strScript += "  Display();";

    strScript += "</script>";
    ScriptManager.RegisterStartupScript(this, this.GetType(), "Startup", strScript, false);
于 2013-11-07T11:03:06.510 に答える