2017-05-12 44 views
2

我想以後後面的一些行動顯示從代碼DIV HTML警報自舉消息, 我使用的Response.Write顯示信息:如何從後面的代碼顯示警報消息?

<html> 
    <head> 
     <link href="bootstrap.min.css"/> 
    </head> 
    <body> 

     <div id="containerMsg"></div> 

     Login design 

    <script src="jquery.min.js"></script> 
    <script src="bootstrap.min.js"></script> 
    </body> 
</html> 

//

串警報CONCAT C#:

public static string msgError(string msg) 
{ 
     string strHtml = ""; 

     strHtml += "<div class='alert alert-warning'>"; 
     strHtml += " <strong>error login:</strong>"+msg; 
     strHtml += "</div>"; 

     return strHtml; 
} 

//Code behind button click 

if(loginBussines.isValid(user)) 
{ 
     Response.Write("<script> $('#containerMsg').html("+UtilsMessage.msgError("invalid credentials")+"</script>") } 
+0

可能重複的[調用JavaScript函數從代碼隱藏](http://stackoverflow.com/questions/5731224/calling-javascript-function-from-codebehind) –

回答

0

嗨,您可以使用JavaScript/Jquery的警報。

這是一個簡單的框架sweetalert。使用方法很簡單

樣本:swal("hello world!");

這裏是鏈接。 http://t4t5.github.io/sweetalert/

+0

順便說一句,這是一個替代Windows警報。 :alert(「Hello world」); –

相關問題