Link to home
Start Free TrialLog in
Avatar of Dan_C
Dan_CFlag for United States of America

asked on

ASP.net Datagrid delete confirmation using VBScript on the Client -Side

Who can I do a delete confirmation on a asp.net DataGrid using vb language on the client and the server. I can't seem to get the submit to cancel when you answer no to the prompt.

---- Server-Side code ---

 If Not (e.Item.FindControl("lnkbutDelete") Is Nothing) Then
    CType(e.Item.FindControl("lnkbutDelete"), LinkButton).Attributes.Add("onClick", "DeleteConfirm()")
End If

---- End Server-Side Code ---


---- Client- Side Code ----
This is the Template column for the delete button in the Datagrid

<ItemTemplate>
<asp:LinkButton id="lnkbutDelete" runat="server" Text="<img border=0 src=images/im_delete.gif alt=delete>"
CommandName="Delete"></asp:LinkButton>
</ItemTemplate>

This is the function I build on the client using the VBscript MSGBOX

Function DeleteConfirm()
If MsgBox ("Are you sure you want to Delete this Record?",4,"Delete Client View Billing Info?") = 6 THEN
Form1_onsubmit =True
Else
Form1_onsubmit = False
End if
End Function

--- End Client-SIde Code ----
Avatar of ihenry
ihenry

use this

CType(e.Item.FindControl("lnkbutDelete"), LinkButton).Attributes.Add("onClick", "return DeleteConfirm()")
Avatar of Dan_C

ASKER

Does not work when using vbScript on the client-side
This should works

CType(e.Item.FindControl("lnkbutDelete"), LinkButton).Attributes.Add("onClick", "eval( 'DeleteConfirm()' )")

Or read this,

http://www.webreference.com/dhtml/column22/js-vbMsgBox.html
Avatar of Dan_C

ASKER

Thanks but I was able to get it to work by using:

 Add("onClick", "javascript: return confirm('Are you sure you want to delete this record?');")

 rather then

.Add("onClick", "return confirm('Are you sure you want to delete this record?');")

I guess I had to explicitly tell it Javascript being I am using vbScript on the client.

Thanks for you help anyway
ASKER CERTIFIED SOLUTION
Avatar of ee_ai_construct
ee_ai_construct
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial