Click here to Skip to main content
15,885,880 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I am using the following common function code in vb.net to show a Java based confirmation window for Delete confirmation.

VB
Public Function fnConfirmation(ByVal page, ByVal message)
        fnConfirmation = ""
        Dim sb As New System.Text.StringBuilder()
        sb.Append("return confirm('")
        sb.Append(message)
        sb.Append("');")

        page.page.ClientScript.RegisterOnSubmitStatement(page.GetType(), "alert", sb.ToString())
        Return fnConfirmation

    End Function


The message pops up and the buttons are clicked. But I am not able to get the value/button information of clicking.

Please guide!

Thanks
Posted
Comments
Wombaticus 16-Aug-14 9:09am    
Presumably your delete operation is tied to a button click event of some kind, in which case you would do better to assign the confirm dialog to that - eg
Button1.Attributes.Add("onclick", "return confirm('Do you really want to delete this?')")
atul sharma 5126 16-Aug-14 9:29am    
Thanks for the reply!
You were right in presuming use of Delete button.

I have added the suggested code in click event of button. But it is not working as I believe the delete command is to be enclosed within IF command based upon result of confirm message. But then again how do I get the return value (ok/cancel)?
atul sharma 5126 16-Aug-14 9:37am    
done!!!

I added the code in page load event and it works..

btnDelete.Attributes.Add("onclick", "return confirm('Do you really want to delete this?')")

Thanks Wombaticus
atul sharma 5126 17-Aug-14 10:23am    
Dear Wombaticus,

The code which worked for delete button is not working for Grid. Pls suggest. following is the code i am using in page load event of page containing grid in which delete is used as command field. following is the related code:

in html grid columns:
<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ShowHeader="True" />

in vb page load:
gdBOM.Attributes.Add("onrowdeleting", "return confirm('Do you want to delete record?')")

'where gdBOM is the name of the grid

Thanks
atul sharma 5126 18-Aug-14 1:11am    
Found the solution..

created a link button and in row data bound added the attribute

1 solution

done!!!

I added the code in page load event and it works..

btnDelete.Attributes.Add("onclick", "return confirm('Do you really want to delete this?')")

Thanks Wombaticus
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900