J
JerryK
I have a piece of asp.net code that sets up a call to a javascript function
in a controls onclick event. This javascript function displays a confirm
dialog and returns the results of the confirm dialog. However, of the user
presses "Cancel" in the confirm dialog, which should return false and cause
the postback to be aborted. However, the postback continues and the Asp.Net
OnClick event handler is called. Anyone know why this happening?
Here is an outline of the code:
a.ascx.vb
.....
Page_load()
if not page.ispostback then
route.attribute("onclick", "MyValidator();")
end if
....
sub route_click(....) handles route.click
I WAS NOT EXPECTING TO GET TO HERE, BUT IT DOES
....
end sub
a.ascx
....
<script language="javascript">
function MyValidator()
{
if(document.all["mycontrol"].value = '')
{ return confirm("a value must be entered"); } THIS IS
DISPLAYED AND Cancel IS PRESSED
else
{ return true; }
}
</script>
Any thoughts,
Jerry
in a controls onclick event. This javascript function displays a confirm
dialog and returns the results of the confirm dialog. However, of the user
presses "Cancel" in the confirm dialog, which should return false and cause
the postback to be aborted. However, the postback continues and the Asp.Net
OnClick event handler is called. Anyone know why this happening?
Here is an outline of the code:
a.ascx.vb
.....
Page_load()
if not page.ispostback then
route.attribute("onclick", "MyValidator();")
end if
....
sub route_click(....) handles route.click
I WAS NOT EXPECTING TO GET TO HERE, BUT IT DOES
....
end sub
a.ascx
....
<script language="javascript">
function MyValidator()
{
if(document.all["mycontrol"].value = '')
{ return confirm("a value must be entered"); } THIS IS
DISPLAYED AND Cancel IS PRESSED
else
{ return true; }
}
</script>
Any thoughts,
Jerry