Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Asp.net RegisterClientScriptBlock

Posted on 2011-02-25
8
Medium Priority
?
744 Views
Last Modified: 2012-05-11
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
Comment
Question by:Angela4eva
  • 4
  • 3
8 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 34982827
if(confirm(' + strmsg + ')){ MyFunctionOnSuccess() }
0
 

Author Comment

by:Angela4eva
ID: 34983244
where should i put this line?
0
 
LVL 28

Expert Comment

by:strickdd
ID: 34984219
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.

 

Author Comment

by:Angela4eva
ID: 34984395
I want to execute the next step if ok, otherwise(Cancel) I want to  return.
I do not want to call a function.
0
 
LVL 28

Accepted Solution

by:
strickdd earned 750 total points
ID: 34984926
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
 

Author Comment

by:Angela4eva
ID: 34985049
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
 
LVL 4

Assisted Solution

by:Tuyau2poil
Tuyau2poil earned 750 total points
ID: 34993559
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
 

Author Closing Comment

by:Angela4eva
ID: 35195419
tahnks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question