Hello!
Can anyone assist? I'm trying to write a custom delete confirmation function for a gridview CommandField(containing a 'delete' Linkbutton), to replace the standard 'confirm' dialog in Javascript, so I can customise the appearance of the box, and its title etc.
(I'm also using VB.NET in Visual Studio 2005, .NET Framework 2.0)
I thought I'd just about it managed it, using a show/hide DIV layer, but I fear I am about to fall at the last (important!) hurdle. Everything works fine, except for one big BUT ... I cannot get the boolean TRUE returned by my Javascript function to trigger a postback/and or the RowCommand event for the gridview concerned. The standard 'confirm' command DOES work, so I dont think it can be an issue with the wiring up of events on the VB.NET side of things.
It's as if the the browser loses track of the event as a result of the call to the client-side confirmation function, which I'm adding to the gvwEnquiries_RowDatabound handler in this way:
Dim lnk As LinkButton = DirectCast(e.Row.Cells(1).Controls(0), LinkButton)
lnk.OnClientClick = "javascript: if (!myConfirm()) {return false;};"
The Javascript seems to work fine in itself, but the boolean return value from the Javascript onclick handler for the INPUTs in the DIV seem to be ignored, regardless of whether TRUE or FALSE is returned. I've tried no end of different return false;/return true; combinations, but I think I might have been barking up the wrong tree.
Instead, does anybody have any opinion on these theories?:
1. Is it because my javascript is split into two functions, a function to show the DIV, and a function to receive the onclick events from the INPUTs in the DIV. But, as I don't think there is a way for Javascript to 'sleep' whilst waiting for a response, I can't think of any other way!
2. The onclick handler IS generated correctly as a result of using the OnClientClick property above, but after running the onclick handler, perhaps the browser does not then move on to the href attribute, which is where the
__doPostBack command which is generated still resides. However, as far as I know, the two should run in this order, without interfering with each other.
I think I'm just going to give up and stick with the standard 'confirm' box unless somebody can give me
a pointer in the right direction, I've spend far too much time trying to sort this out already, but am I missing something obvious?!
Please help if you can!!
Regards
Paul
Can anyone assist? I'm trying to write a custom delete confirmation function for a gridview CommandField(containing a 'delete' Linkbutton), to replace the standard 'confirm' dialog in Javascript, so I can customise the appearance of the box, and its title etc.
(I'm also using VB.NET in Visual Studio 2005, .NET Framework 2.0)
I thought I'd just about it managed it, using a show/hide DIV layer, but I fear I am about to fall at the last (important!) hurdle. Everything works fine, except for one big BUT ... I cannot get the boolean TRUE returned by my Javascript function to trigger a postback/and or the RowCommand event for the gridview concerned. The standard 'confirm' command DOES work, so I dont think it can be an issue with the wiring up of events on the VB.NET side of things.
It's as if the the browser loses track of the event as a result of the call to the client-side confirmation function, which I'm adding to the gvwEnquiries_RowDatabound handler in this way:
Dim lnk As LinkButton = DirectCast(e.Row.Cells(1).Controls(0), LinkButton)
lnk.OnClientClick = "javascript: if (!myConfirm()) {return false;};"
The Javascript seems to work fine in itself, but the boolean return value from the Javascript onclick handler for the INPUTs in the DIV seem to be ignored, regardless of whether TRUE or FALSE is returned. I've tried no end of different return false;/return true; combinations, but I think I might have been barking up the wrong tree.
Instead, does anybody have any opinion on these theories?:
1. Is it because my javascript is split into two functions, a function to show the DIV, and a function to receive the onclick events from the INPUTs in the DIV. But, as I don't think there is a way for Javascript to 'sleep' whilst waiting for a response, I can't think of any other way!
2. The onclick handler IS generated correctly as a result of using the OnClientClick property above, but after running the onclick handler, perhaps the browser does not then move on to the href attribute, which is where the
__doPostBack command which is generated still resides. However, as far as I know, the two should run in this order, without interfering with each other.
I think I'm just going to give up and stick with the standard 'confirm' box unless somebody can give me
a pointer in the right direction, I've spend far too much time trying to sort this out already, but am I missing something obvious?!
Please help if you can!!
Regards
Paul