.NETGURU
return confirm no longer working on ASP.net page
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.jscript.

Post a new message to this list...

CapCity
We have a few ASP.net apps where we needed confirmation dialogs with buttons
in datagrids. The code goes something like this (in the ItemDataBound event
for the grid):

strJavaScript = "javascript: return confirm('Any changes made to this
scenario cannot be reversed. Also, results to a changed scenario cannot be
viewed until the scenario is submitted again. Continue with edit of scenario
?');"
btnLink = CType(e.Item.FindControl("cmdSelect"), LinkButton)

btnLink.Attributes.Add("onClick", strJavaScript)

This has worked flawlessly until recently. Now, on my development machine,
the dialog will still appear, but no matter which button I click it goes
ahead as if I clicked "OK". The other developers do not have this issue, it
still works for them. This happens with apps that have been in production
for a while. A few weeks ago it worked fine from my machine, now it doesn't.

My guess is that it is my browser. It's IE 6.0.2800.1106 SP1. Several of the
"Q" updates have been pushed onto machine, but nothing that the other
machines don't have. Security settings in IE look kosher. It seems as if the
javascript is running because I see the dialog. It seems that the "return"
value is being ignored.

Anyone ever experience something like this? I've googled, but no luck. Maybe
not wording it correctly.

Thanks for any insight you can provide.

Reply to this message...
 
    
Vidar Petursson
Hi

Loose the javascript: bit
btn.Attributes.Add("onclick","return confirm('blah')");

--
Best Regards
Vidar Petursson
==============================
Microsoft Visual: Scripting MVP 2000-2004
http://www.icysoft.com/
http://www.deus-x.com/ Instant e-commerce
http://www.microsoft.com/technet/scriptcenter/
Playground: http://213.190.104.211/ ( IE 5.5+ only )

No matter where you go there you are
==============================
"CapCity" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
CapCity
"Vidar Petursson" <Click here to reveal e-mail address> wrote in
message news:%Click here to reveal e-mail address...
[Original message clipped]

Thanks for the response, but it made no difference. Still behaves the same
way.

When I view the source I can see the code in there for the onclick, so
that's being recognized.

[Original message clipped]

Reply to this message...
 
    
bruce barker
its a known IE bug. it fails cancel the postback based on the return value.
while there is no fix, there is a workaround.

allowPostbackScript = @"<script>
function allowPostback(v) {
if (!v && document.all) event.returnValue = false;
return v;
}
</script>
";

RegisterStartupScript("allowPostback",allowPostbackScript );

strJavaScript = "javascript: return allowPostback(confirm('Any changes made
to this
scenario cannot be reversed. Also, results to a changed scenario cannot be
viewed until the scenario is submitted again. Continue with edit of
scenario
?'));"

-- bruce (sqlwork.com)

"CapCity" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> We have a few ASP.net apps where we needed confirmation dialogs with
buttons
> in datagrids. The code goes something like this (in the ItemDataBound
event
[Original message clipped]

Reply to this message...
 
 
System.Web.UI.WebControls.LinkButton




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification