• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 752
  • Last Modified:

Asp.net RegisterClientScriptBlock

I am calling this javascript from my asp.net. Can some one please let me know how i can catch whether user select Ok or cancel and do something?
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "showmessage", "confirm('" + strmsg + "');", true);
i want to know whether the use click Ok or cancel and do if Ok return and Cancel nothing
0
Angela4eva
Asked:
Angela4eva
  • 4
  • 3
2 Solutions
 
strickddCommented:
if(confirm(' + strmsg + ')){ MyFunctionOnSuccess() }
0
 
Angela4evaAuthor Commented:
where should i put this line?
0
 
strickddCommented:
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "showmessage", "if(confirm(' + strmsg + ')){ MyFunctionOnSuccess() };", true);
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Angela4evaAuthor Commented:
I want to execute the next step if ok, otherwise(Cancel) I want to  return.
I do not want to call a function.
0
 
strickddCommented:
What is "the next step". You asked how to implement a confirm box and know whether the users selects OK or Cancel... that's what I gave you.
0
 
Angela4evaAuthor Commented:
next step is next line after
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "showmessage", "if(confirm(' + strmsg + ')){ MyFunctionOnSuccess() };", true);
even the your script form does not work.
0
 
Tuyau2poilCommented:
Well, you can't run client side code (for example javascript messagebox) and get immediate result in code behind because code behind is server side.
code behind need a postback to read client input, so code excution must stop and page reload before continuing.... impossible in this case to run code, ask something to user, and continue execution.
Only Javascript can do it, but javascript is not code behind....
I hope my explanation is not too tricky... I'm French and my english is in beta test !
0
 
Angela4evaAuthor Commented:
tahnks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now