calvin Posted January 20, 2005 Posted January 20, 2005 I have a datagrid and allow to delete function. But before delete the record, I want to popup a message(using javascript alert message) to confirm to delete record. If user select "Yes" then, I want to call a server side function to check whether the record can be delete or not. So, my problem is start from calling the server side function using javascript. Is it possible to do that. If so, please give me a solution/help. Else any idea to solve the problem??? Below is part of my code to do the delete record command:- Private Sub Delete(ByVal Source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand Dim strScript As String = "<SCRIPT language='javascript'>" & Environment.NewLine strScript = strScript + "if(confirm('Are you sure to delete?')){document.getElementById('" & txtbox.ID & "').value = 'Yes';***}else{document.getElementById('" & txtbox.ID & "').value = 'No';}" & Environment.NewLine strScript = strScript + "</script>" RegisterStartupScript("focus", strScript) Dim strLocationID As String = e.Item.Cells(2).Text If txtbox.Text = "Yes" Then 'Do a lot of coding here and call function Else ' Do nothing End If End Sub ***Notice the code in red color, it suppose to put inside a (serverside??)function and to be call by javascript function(notice the blue (*)marks), because it will run the code when page is rendered. Thank you for help and comments. Calvin Quote
Administrators PlausiblyDamp Posted January 20, 2005 Administrators Posted January 20, 2005 clicky may be worth a read Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.