How do i convert this code snippet to c#
<p>I am trying to figure out <a href="http://stackoverflow.com/questions/4747702/implementing-javascript-confirm-box-in-code-behind-on-drop-down-boxs-selected-in">how to display confirm box when drop down list's selected indexchanged</a> event is fired.  </p>

<p>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.</p>

<pre><code>Public Sub ConfirmOnChange()
            'Register the script block
            If Not IsStartupScriptRegistered("CSP-ddl-onchange") Then
                RegisterStartupScript("CSP-ddl-onchange", _
                    "&lt;script language=""JavaScript""&gt;" &amp; _
                    "var CSP_savedDDLID = " &amp; _
                     "document.getElementById('" &amp; _
                     ddl.ClientID &amp; "').value;" &amp; vbCrLf &amp; _
                    "function resetDDLIndex() {" &amp; vbCrLf &amp; _
                    " document.getElementById('" &amp; _
                     ddl_Status.ClientID &amp; "').value = CSP_savedDDLID;" &amp; _
                    vbCrLf &amp; _
                    "}" &amp; vbCrLf &amp; _
                    "&lt;/script&gt;")
            End If
            Dim msg As String = "'Do you want to change selection?';"
            ddl_Status.Attributes("onchange") = _
            "if (!confirm('" &amp; msg.Replace("'", "\'") &amp; _
            "')) resetDDLIndex(); "
        End Sub
</code></pre>
