简体   繁体   English

Asp.NET C#中的消息框

[英]Message box in Asp.NET C#

How to display a 1056 character message in message box in asp.NET C#. 如何在ASP.NET C#的消息框中显示1056个字符的消息。

 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. 上面的代码仅接受54个字符。我需要其他方法来显示整个页面的错误消息。

I would use jQuery instead. 我会改用jQuery。 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/ 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. 我不知道JavaScript警报的最大限制,但肯定超过54个字符。 You may need to insert line breaks (\\n) to force the text over several lines. 您可能需要插入换行符(\\ n),以迫使文本跨越多行。 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/). 您需要使用jQuery UI对话框(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. 其中dialog是div标签的ID,该标签包含要显示为对话框的内容。

you can try this in your codebehind. 您可以在背后的代码中尝试。

String csname1 = "PopupScript";

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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