private void ShowMessageBox(string Message)
{
Label lblMessageBox = new Label();
lblMessageBox.Text =
"#script language='javascript'#" + Environment.NewLine +
"window.alert('" + Message + "')#/script#";Page.Controls.Add(lblMessageBox);
}
To call the message box function and just pass message value :
ShowMessageBox("Cannot Delete!");