cks
cks

Reputation: 153

How to alert and redirect using sweet alert in asp.net

ScriptManager.RegisterStartupScript(this, this.GetType(), 
"alert", 
"alert('User details saved successfully');window.location ='frmDisplayUsers.aspx';", 
true);

Upvotes: -1

Views: 2479

Answers (2)

cks
cks

Reputation: 153

ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "swal('Done !!!','User details saved successfully','success').then((value) => { window.location ='frmDisplayUsers.aspx'; });", true);

this was what i wanted.....

Upvotes: -1

Sergiu Muresan
Sergiu Muresan

Reputation: 539

You need to add a referene to the SweetAlert library in the head section of the page:

<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

Then you need to change your code to this:

ScriptManager.RegisterStartupScript(this, this.GetType(), 
"alert",
"swal('User details saved successfully').then((value) => { window.location ='frmDisplayUsers.aspx'; });", 
true);

Upvotes: 1

Related Questions