How to show a message box in an ASP.NET page?

前端 未结 8 667
青春惊慌失措
青春惊慌失措 2020-12-20 01:34

As I was a Windows programmer it was so easy to show a message box on a form.

But on an ASP.NET page I don\'t know how can I show it?

Actually I have some co

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-20 01:59

    The only way to show a Yes No dialog, is to design a custom one (Javascript confirm can only produce OK and Cancel).

    Luckily, ASP.NET Ajax controls (Ajaxcontroltoolkit) makes this job easy, as you can have a panel as your messagebox with the buttons you want, and have a ModalPopupExtender to imitate a dialog.

    EDIT:

    For what you ask with javascript, you can do it (and it is a much simpler solution than any seen so far), but prepared to only have OK and Cancel as the two possible answers. UI Designer Nightmare ! :(

    Basically, have the following two properties in your aspx page for that button or whatever:

    onClientClick = "javascript:confirm('you sure you wanna do this?');" onClick="myButton_Click"
    

    onClick will only run if OK is pressed on the msg dialog.

提交回复
热议问题