Niranjan Thangaiya
Niranjan Thangaiya

Reputation: 515

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.

Upvotes: 0

Views: 8545

Answers (5)

awrigley
awrigley

Reputation: 13581

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.

Upvotes: 0

anishMarokey
anishMarokey

Reputation: 11397

you can try this in your codebehind.

String csname1 = "PopupScript";

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

Upvotes: 0

Michael Gattuso
Michael Gattuso

Reputation: 13200

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.

Upvotes: 1

rboarman
rboarman

Reputation: 8214

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/

Upvotes: 4

Stefan P.
Stefan P.

Reputation: 9519

You can use the ModalPopup component from Ajax control toolkit.

Upvotes: 1

Related Questions