Question Confirm before insert in a DetailView

Dusse

New member
Joined
Jun 6, 2011
Messages
2
Programming Experience
1-3
Hello Guys, I´m new in the forum and also new in Vb.net.
I have a code of a website to maintain that has a Detailview and a GridView in the same page. In the insert mode the users may fill the DetailView, click on Insert Command Field and, before it commit in my database, they must confirm if they really want to insert that information.
How can I do it? I know that I have to use javascript but I don´t know how.
 
Just add this code to the button TAG(s) and it will work:

OnClientClick="return confirm('Do you really want to insert this data?')"


So now, a pop up will come up with the Question. If they hit Ok, the page will post back and save the information, if they hit cancel, the form will be not submitted.
 
Thanks Kuron for the reply. But it isn´t too simple and I did not explain what I really want.
The page doesn´t have a button. It uses CommandField. And the confirm dialog will appear only if a CheckboxField is checked
 
Well you can reference the Insert button using the FindControl method from DetailsView e.g.

Dim InsertButton As LinkButton = CType(Me.DetailsView1.FindControl("MyInsertButton"), LinkButton)
InsertButton.Attributes.Add("onclick", "javascripthere")


However, i would suggest to use template for this. CommandField is not the best way to go in this scenario.
 
Back
Top