0

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.

1
  • 1
    That would be rather annoying, dont you think? Why not present it on a nice scrollable formatted page? Commented Nov 11, 2010 at 12:01

5 Answers 5

4

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/

Sign up to request clarification or add additional context in comments.

Comments

1

You can use the ModalPopup component from Ajax control toolkit.

Comments

1

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.

Comments

0

you can try this in your codebehind.

String csname1 = "PopupScript";

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.