chetan chandan

chetan chandan

  • 1.6k
  • 39
  • 14.9k

How to return values from scriptmanager.RegisterStartUpScrip

Jun 10 2014 2:52 AM
Hi,
 
I have this requirement in which i have to check for different conditions and based on its value a confirm box must be displayed with different messages. I have been successful in calling the confirm box from my aspx.cs file using ScriptManager.RegisterStartUpScript. The problem i am facing is i need to check the return value of this " ScriptManager.RegisterStartupScript(this, this.GetType(), "confirm", "javascript:confirm('Are you sure you want to delete');", true); " . To check the user has clicked which button Ok/Cancel. So i tried implementing it in these two different ways:
 
1. ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "javascript:if(confirm('Are you sure you want to delete') == false) return false;", true);
 
2. ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "javascript:return confirm('Are you sure you want to delete');", true);
 
But no success, with these approaches confirm box doesn't even appear  and I am not using any client side code in the aspx page. 
 
Any kind of help will be appreciated. 
 
Thanks in advance. 

Answers (1)