简体   繁体   中英

Message box in Asp.NET C#

How to display a 1056 character message in message box in asp.NET C#.

 Response.Write("<script>alert(' " + a + " ')</script>");

The above code just accepts 54 characters only.I need some other way to display the error messages for a whole page.

I would use jQuery instead. It's a lot more friendly to the user than an alert and more flexible. There's a modal version if you need that as well.

http://jqueryui.com/demos/dialog/

您可以使用Ajax控件工具箱中的ModalPopup组件。

I don't know the max limit of javascript alerts but it is certainly more than 54 chars. You may need to insert line breaks (\\n) to force the text over several lines. As others have mentioned though I would also look at alternatives to displaying this in the alert box.

You need to use the jQuery UI dialog (http://jqueryui.com/demos/dialog/). It allows you to write things like:

<script type="text/javascript">
        $(function () {
            $("#dialog").dialog({
                bgiframe: true,
                draggable: true,
                resizable: true,
                height: 460,
                width: 800,
                modal: true,
                buttons: {
                    Ok: function () {
                        $(this).dialog('close');
                    }
                }
            });
        });
    </script>

Where dialog is the id of a div tag that holds the content you want to display as a dialog.

you can try this in your codebehind.

String csname1 = "PopupScript";

            String cstext1 = "<script type=\"text/javascript\">" +
            "alert('ssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssdssssd');</" + "script>";
            RegisterStartupScript(csname1, cstext1);

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