Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Asp.net RegisterClientScriptBlock

Posted on 2011-02-25
8
725 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

839 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