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
  • 145
  • 1
  • 13

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
  • 153,850
  • 22
  • 249
  • 325
MatteoSp
  • 2,940
  • 5
  • 28
  • 36
0

Write like this..

ScriptManager.RegisterStartupScript(this,GetType(),"showalert","alert('Only alert Message');",true);
Rajeesh Menoth
  • 1,704
  • 3
  • 17
  • 33
  • 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
  • 222
  • 2
  • 12