This is a migrated thread and some comments may be shown as answers.

Allowed content for RADAlert?

4 Answers 145 Views
Window
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 21 Nov 2011, 10:38 PM
I'm trying to use RadAlert in my .Net 4.0 web form/app and have found that trying to display certain text makes the window fail to appear.
I was trying to put a html table in mine and when I do the alert doesn't ever show up when called. Using the same code I can make the window display with no html tags involved. From what I have read html should be allowed, right?

If my message is "Testing 123" the window pops up.

If my message is a html table, the window doesn't pop up, like this:
"<table>
    <tr>
        <td>
            Label:
        </td>
        <td>
            Value
        </td>
    </tr>
</table>"

But a simpler html snippet like this does pop up:
Label:   <i>value</i> <br />

Is there a resource that will show me exactly what is or isn't allowed? Or is it a length restriction? Thanks!

4 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 22 Nov 2011, 02:21 PM
Hello Matt,

I don't see an issue with passing html content into the radalert method. I'm calling it like so:

radalert("<table><tr><td>Label:</td><td>Value</td></tr></table>");

Does that not work for you?

0
Marin Bratanov
Telerik team
answered on 22 Nov 2011, 04:59 PM
Hello Matt,

I also tried this code and things worked as expected with me: http://screencast.com/t/lzkkY42UG. I am also attaching my test page here. Can you reproduce this behavior with it?

I would also ask you to confirm there isn't a JavaScript error before the RadAlert is called, as this would prevent it from executing.

Are you also using the quote marks? Since this content needs to be handled via JavaScript you may need to escape symbols with special meaning for this language - quotes (single or double) as they are a string delimiter, backslashes, etc.

Generally the RadAlert supports HTML strings, the only peculiarity is that this string passes through JavaScript so it needs to be properly escaped and delimited.

As for the length - it can take much longer messages than this and the length is practically not limited.


Greetings,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Matt
Top achievements
Rank 1
answered on 29 Nov 2011, 11:02 PM
Thanks for the reply and sorry I took so long to get back.

I'm calling this alert from codebehind triggered by events from RadScheduler like this:

    private void ShowPopUp(string heading, string message)
    {
        string radalertscript = "<script language='javascript'>function f(){radalert('" + "<p><h2>" + heading + "</h2></p>" + message + "', 330, 210); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);
    }

Could the way I'm approaching this be the cause of my problems? I read this:
http://www.telerik.com/help/aspnet/window/callingradalertfromcodebehind.html

Which says: "The task gets complicated if Ajax is used because the page does not reload and window.onload is fired only once (when the page is initially shown). When using Ajax you must apply an appropriate solution depending on the exact case."

So I think I may have hit that complicated scenario because RadScheduler is using Ajax and my page doesn't do postbacks. Got any suggestions? I just wanted a simple way to pop up a dialog with html in it to display to the user.
Thanks!
0
Kevin
Top achievements
Rank 2
answered on 30 Nov 2011, 01:56 PM
Hello Matt,

If your using the RadAjaxManager or RadAjaxPanel, you use this to show the radalert:

string radAlertScript = ("radalert('" + "<p><h2>" + heading + "</h2></p>" + message + "', 330, 210);";
RadAjaxManager.GetCurrent(Page).ResponseScripts.Add(radAlertScript);

You can just add it the javascript call to the ResponseScripts collection of the RadAjaxManager or RadAjaxPanel control.

I hope that helps.
Tags
Window
Asked by
Matt
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Marin Bratanov
Telerik team
Matt
Top achievements
Rank 1
Share this question
or