0

I have been trying with below code its getting execute but messagebox not displaying and tab also not getting close.

ScriptManager.RegisterStartupScript(this, this.GetType(), "Messagebox", "alert('Record Deleted successfully.Note: This tab is now getting close');", true);

so i just remove the 'alert' code from above code then its getting execute and getting close the tab. But I also want to display notification message box so how?

ScriptManager.RegisterStartupScript(this, this.GetType(), "Messagebox", "window.close();", true);
abbas arman
  • 125
  • 11

3 Answers3

2

Just combine both calls into one, and call the one after the other:

ScriptManager.RegisterStartupScript(this, this.GetType(), "Messagebox", "alert('Record Deleted successfully.Note: This tab is now getting close');window.close();", true);
Patrick Hofman
  • 148,824
  • 21
  • 237
  • 306
MatteoSp
  • 2,912
  • 5
  • 25
  • 36
0

Write like this..

ScriptManager.RegisterStartupScript(this,GetType(),"showalert","alert('Only alert Message');",true);
Rajeesh Menoth
  • 1,608
  • 2
  • 17
  • 31
  • ScriptManager.RegisterStartupScript(this, this.GetType(), "Messagebox", "alert('Record Deleted successfully.Note: This tab is now getting close');", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "Messagebox", "window.close();", true); – abbas arman May 04 '15 at 09:52
0

try from javascript

<script type="text/javascript">
    function Showalert() {
        alert('Call JavaScript function from codebehind');
        window.close();
    }
</script>

and then call it from your codebehind side werever you want.

ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "Showalert();", true);

hopw this will help you. thanx.

Dawood Abbas
  • 212
  • 2
  • 11