我们可以在aspx中显示2(javascript)警报吗?
如果可能,任何人都可以帮助如何显示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)
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);
}