Tuesday, 17 September 2013

JAVASCRIPT ALERT ON CLASS PAGE



----------------.aspx--------------
JAVASCRIPT FUNCTION
function alertClick(Details)
{
alert(Details)
return false;
}
.CS    
string alert = "Enter Atleast One Debit Type and One Credit Type Ledger";
RegisterClientScriptBlock("gridcount", "<script Language='javascript'>window.onload = function(){return alertClick('" + alert + "');}</script>");
return;

 ---------------- OR

protected void Page_Load(object sender, EventArgs e)

{

  string message = "Hello! Mudassar.";

  System.Text.StringBuilder sb = new System.Text.StringBuilder();

  sb.Append("<script type = 'text/javascript'>");

  sb.Append("window.onload=function(){");

  sb.Append("alert('");

  sb.Append(message);

  sb.Append("')};");

  sb.Append("</script>");

  ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());

}
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.