473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using javascript return confirm function within asp.net sub

I'm trying to use the following code to use a javascript return confirm.
Cancel would exit the sub and return the page to its history (-2).

OK would proceed with the asp.net code, i.e., run the Complete() sub.

This is within a page that will take me quite a while to test, so I'd
like to know if I've got this right beforehand. I think I'm missing
something...but not sure what? Never used this before in this way.

...within a Sub...

If varTestStatus = "F" Then
RegisterClientScriptBlock("ConfirmTestFail", "<script
language='javascript'>return confirm(""Click Cancel to
return to the instruction page.\n\nOR...click OK to
continue running this code."");self.history.go(-2);
</script>")
'if Cancel clicked
Complete()
End If

TIA!
Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
2 7030
Hi,

I think you mean :

if (!confirm("Click Cancel to return to the instruction page.\n\n
OR...click OK to*continue running this code."))
{
self.history.go(-2);
}

I can’t see where you attach this block to event or you meant to use
registerstartupscript. Anyway if I understood you want to call server
side code if the user presses OK. If so you can’t do it the way you
write it, when the client side script took place the server side code
not exists anymore. The best way to so is to cause postback if the user
click "OK"

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
Thanks, Natty.

Yes, I'm using RegisterClientScriptBlock. Would the following work from
with asp.net code? If OK, I would like to open a new page
(Proceed.aspx), if Cancel, would like to return to originating html page
(needs history (-1) or it remains blank.

Using RegisterClientScriptBlock, will the following work (clearly this
is not my area of even semi-expertise!). It needs to initiate from code
(not a button). It's in an If statement (e.g., If test_status = "F"
Then...)

RegisterClientScriptBlock("ConfirmFail", "<script
language='javascript'>if(confirm(""TEST FAILED.\n\nClick CANCEL to
return to the instruction.\n\nOR...click OK to continue the process
selected."")){parent.right.location='Proceed.aspx' ;;return true} else
{parent.right.history.go(-1);}</script>")

I would then move the "continue process" code to the proceed.aspx page.

Am I still off track?

BTW, this is a left/right frame setup.

Thanks again.
Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
4
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
7
by: Tigger | last post by:
Dear Experts, I am working on ASP.NET. I have got a problem related to the usage of Javascript in ASP.NET. Please help. The story is the following: 1) I am developing an ASP.NET application. I...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
12
by: tshad | last post by:
I have the following code that attaches a Javascript confirm box to my checkbox. When I select the checkbox, the window comes up fine, but it never executes the XfertoDefault_Click function when I...
8
by: Dave | last post by:
Hello all, I have been able to use a Javascript alert box in my vb.net web application, for example: Dim msg As String = "Hello, world." Dim alertScript As String = "<script...
2
by: mark4asp | last post by:
How do I include a server tag within a javascript parameter which is itself within a HTML element event. For instance no matter what permutation of quotes I try here I get errors on this line: ...
1
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.