2017-05-25 2 views
-3

2(JavaScript)アラートをaspxに表示できますか?Cで同じ方法で2つのアラートボックスを表示するには

可能であれば誰もが更新2つのアラート

public void ShowAlert() 
     { 
      string value = "9494949494"; 
      string message = "alert on " + value; 
      string script = "alert('" + message + "');"; 
      ScriptManager.RegisterStartupScript(this, typeof(Page), "UserSecurity", script, true); 
     } 
+0

コードがあるの?次々に2つの警告文を入れようとしましたか?それは動作しましたか?それは何を示しましたか?エラーはありますか? –

+0

上記のコードでは、アラートを取得するために使用していますが、1つ後に1つを表示するために使用しています... – Basha

+0

スクリプトでは、2つのアラート・ステートメントを次々に入れることができます。 –

答えて

2
public void ShowAlert() 
    { 
     string value = "9494949494"; 
     string message = "alert on " + value; 
     string script = "alert('" + message + "');"; 
     string script2 = "alert('" + message + "');"; 
     var myScripts = new List<String>(); 
     myScripts.AddRange(script, script2); 

     foreach(var s in myScripts) 
     { 
      ScriptManager.RegisterStartupScript(this, typeof(Page), 
      "UserSecurity", s, true); 
     } 

    } 

を表示する方法を助けることができる:

以上の合理的なアプローチ

public void ShowAlert() 
    { 
     string value = "9494949494"; 
     string message = "alert on " + value; 
     string script = "alert('" + message + "');"; 
     string script2 = "alert('" + message + "');"; 
     var myScripts = script + script2 

     ScriptManager.RegisterStartupScript(this, typeof(Page), 
     "UserSecurity", myScripts, true); 


    } 
+0

アラートを単一の文字列に追加するだけで、リストとループを作成する理由 – niksofteng

+0

ありがとうChef_Code。 – Basha

関連する問題