Solved

Asp.net RegisterClientScriptBlock

Posted on 2011-02-25
8
724 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

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 250 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 250 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 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