I am trying to figure out how to display confirm box when drop down list's selected indexchanged event is fired.
Browsing thru some forum I came across the following solution but I dont know how I can use it as I am working in c#. How do I make it work? I am not even sure if this is really the solution to my problem. Some one please help.Thanks.
Public Sub ConfirmOnChange()
'Register the script block
If Not IsStartupScriptRegistered("CSP-ddl-onchange") Then
RegisterStartupScript("CSP-ddl-onchange", _
"<script language=""JavaScript"">" & _
"var CSP_savedDDLID = " & _
"document.getElementById('" & _
ddl.ClientID & "').value;" & vbCrLf & _
"function resetDDLIndex() {" & vbCrLf & _
" document.getElementById('" & _
ddl_Status.ClientID & "').value = CSP_savedDDLID;" & _
vbCrLf & _
"}" & vbCrLf & _
"</script>")
End If
Dim msg As String = "'Do you want to change selection?';"
ddl_Status.Attributes("onchange") = _
"if (!confirm('" & msg.Replace("'", "\'") & _
"')) resetDDLIndex(); "
End Sub