简体   繁体   中英

How to offer a 'confirm' dialog which then fires server-side code

I have been given the task to re-code an old VB6 page. This page exports data from our database and imports it into another. While the export/import is happening, I need to offer the user confirm boxes. The context and results of these confirm boxes all depend on server-side validation. In the old code, the author simply did:

If MsgBox(Msg, vbOKCancel) = vbOK Then
    GoTo Function1
Else
    GoTo Function2
End If

Yes, those are GoTos, don't remind. This code is rough. Anyway, how in the heck can I do this in .NET with c# code behind?

Well the code would be the same if it were C#, though it would look something like:

if (Interaction.MsgBox(Msg, Constants.vbOKCancel) == Constants.vbOK) {
    goto Function1;
}
else {
    goto Function2;
}

But, if this is an ASP.NET application, it would look different. You'd probably make a modal dialog box and attach some click handlers to the buttons on that dialog.

[edit] By the way, if you're ever in doubt about how VB code would look in C#, try a converter utility such as this one. They don't work all the time, but they work sometimes. Cheers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM