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

Using radalert as server side "MessageBox"

21 Answers 1153 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mats
Top achievements
Rank 1
Mats asked on 07 Feb 2008, 03:52 PM
Hi!

I am currently moving from RadControls for ASP.NET to Prometheus. I have a problem with the radalert function. It works fine in RadControls for ASP.NET but not in Prometheus.
I want to generate a "message box" with a message generated on server. I do it by registering a startup script in the script manager.
Using standard windows alert from server as well as radalert from client works fine.
But as soon as I use radalert from server then the radalert is 'undefined'. I guess that the RadWindowManager is 'undefined'.

How can I solve this problem?

Small code sample is attached below.

Thanks
/Mats

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>RadAlert</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        </telerik:RadWindowManager>
        <asp:Button ID="AlertButton" runat="server" OnClick="AlertButton_Click" Text="Alert from server" />
        <asp:Button ID="RadAlertButton" runat="server" OnClick="RadAlertButton_Click" Text="RadAlert from server" />
        <input id="RadAlertButtonClient" type="button" value="RadAlert from client" onclick="radalert('Some data from client!');"/>
    </form>
</body>
</html>

Default.aspx.cs:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void AlertButton_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "AlertScript", "alert('Some data from server!');", true);
    }

    protected void RadAlertButton_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "RadAlertScript", "radalert('Some data from server!');", true);
    }
}

21 Answers, 1 is accepted

Sort by
0
jai
Top achievements
Rank 1
answered on 08 Feb 2008, 12:43 PM
Hi,

Im also facing the same issue, let check my code that given below. Let guide us to migrating RadControls to Prometheus Controls in our project.

Master page.

<telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>

Content Page:

On Button Click- CodeBehind

string windowScript = "<script language=javascript>window.radopen('RadGrid.aspx')</script>";
ClientScript.RegisterClientScriptBlock(Page.GetType(),
"LoginWindowScript", windowScript);

-------------
Looking forward of ur response

Regards
Jai

0
Svetlina Anati
Telerik team
answered on 08 Feb 2008, 01:19 PM
Hi Mats,

The controls in the Prometheus suite are built upon the MS AJAX framework and the framework itself creates its controls (including RadWindow Prometheus) in the Sys.Application.add_init() method - you can check this for yourself by examining the HTML dump of a page with RadControls Prometheus included in it (or any other ASP.NET AJAX control). That is why when you call your code when the page is loaded, the RadWindow will still not be fully rendered on the page and you will get the error. To avoid this issue, you can either execute your code with a small timeout or better - to add your code in the Sys.Application load handler as shown below:

  protected void RadAlertButton_Click(object sender, EventArgs e)  
    {  
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "RadAlertScript""Sys.Application.add_load(function(){radalert('test');});"true);  
    } 


Kind regards,
Svetlina
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
jai
Top achievements
Rank 1
answered on 08 Feb 2008, 03:29 PM
Hi Svetlina,

Its working fine for me. Thanks.
0
Mats
Top achievements
Rank 1
answered on 08 Feb 2008, 04:19 PM
Hi!

It works great! Thanks for the info.

/Mats
0
Adam
Top achievements
Rank 1
answered on 08 Feb 2008, 10:12 PM
 Hi,

I'm having the same issue, and I tried the fix. The radalert shows up with the correct text, etc but the fix causes an exception.

This is an invalid webresource request.
at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Any idea's on how to completely fix this issue?

Thanks
-Adam
0
Georgi Tunev
Telerik team
answered on 11 Feb 2008, 11:27 AM
Hello Adam,

Can you please open a support ticket and send us a small sample project where the last problem can be reproduced? Once we can examine the problem locally, we will do our best to provide you with the most appropriate solution.



Greetings,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mats
Top achievements
Rank 1
answered on 11 Feb 2008, 12:47 PM
Hi!

I still have two problems:

1) When I close the radalert with Esc key then the next time I try to open it then I will get a jscript error: "length is null or not an object".
This is easily reproduced in a small test application.

2) The radalert is not centered. It shows in the left , top corner.
This only happens in my real application. In a small test application the radalert is centered!

/Mats
0
Georgi Tunev
Telerik team
answered on 14 Feb 2008, 02:14 PM
Hello Mats,

Regarding p.1, we managed to reproduce the problem locally and it will be fixed for the next service pack which will appear in 2 weeks. Thank you for bringing it to our attention - your points were updated.

As for the second issue, I am afraid that without a reproduction which we can examine, we cannot be of much help. If you manage however, to isolate the problem, please send it to us and we will check it right away.





Kind regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mats
Top achievements
Rank 1
answered on 20 Feb 2008, 09:50 AM
Hi!

I have now found what is the difference in my projects that causes the radalert window not to be centered.

If I set the DOCTYPE the same as in an ASP.NET Ajax Enabled Website in the aspx file then the window will be centered.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Does this make sence?

/Mats
0
Georgi Tunev
Telerik team
answered on 20 Feb 2008, 11:51 AM
Hi Mats,

Indeed, RadWindow "Prometheus" (and all controls from the "Prometheus" suite) are built upon the MS AJAX framework which works with XHTML Doctype. The controls rely on that Doctype to be able to correctly calculate their position on the page.



Greetings,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Vishal
Top achievements
Rank 1
answered on 24 Jul 2008, 11:04 AM
Hi Svetlina,

Thanks for the detail explanation, it's relly helpful. But with this solution it display the window again when page gets load even though second time does not get register.

It would be great if you help me to resolve this issue.

Regards

Vishal Patel
0
B
Top achievements
Rank 1
answered on 25 Jul 2008, 07:00 PM
ScriptManager.RegisterStartupScript(Page, typeof(Page), "RadAlertScript", "Sys.Application.add_load(function(){radalert('test');});", true); 

This worked great for me. I have a couple of questions though.

1. How do you set where the window opens in the browser? I need mine to open in the top left corner.

2. How do you set the title of the window?

Basically how do you set properties on the window when you open on the server side like this.

Thank you,
Blake
0
Svetlina Anati
Telerik team
answered on 28 Jul 2008, 02:11 PM
Hello guys,

Straight to your questions:

  1. Vishal, I already answered your other thread and I think that it will be best to continue discussing your scenario there.
  2. Blake, I am not quite sure whether you mean a RadWindow or a RadAlert - you talk about RadWindow and your code shows a radalert. That is why I will answer your questions for both of the dialogs.

    1. Positioning question:
         - RadWindow - you can specify the position by setting the Top and the Left properties
         - radalert - you cannot reposition the radalert, it is shown at the center of the screen by default because this is the behavior of the standard alert dialog, too.


    2. Title question:
        - RadWindow - set the Title property - you can do this in the code-behind.
        - radalert - you can provide the title as an argument in the radalert definition as explained here.

As to your other question, you can set the RadWindow's properties on the server after you have referenced it, e.g:

RadWindow1.Title = "RadWindow1 Custom Title"

or in case you are using RadWindowManager:

 RadWindowManager1.Windows[0].Title = "Custom Title";  
        RadWindowManager1.Windows[0].VisibleOnPageLoad = true



Kind regards,
Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
B
Top achievements
Rank 1
answered on 28 Jul 2008, 02:29 PM
Thank you for the answers to my questions. I was originally talking about the rad alert, but now that I see I cannot change the position of the window I am going to need to use a different control. Let me explain what I am trying to do and maybe you can point me in the right direction

My page currently consists of a splitter with two panes. On one side, there is a menu, and on the other a PDF is displayed based on what is clicked on in the menu. When I use the radalert, the window alert pops up, but I a cannot see half of it because it is behind the PDF. Basically I need a window that will do the following:

- Display a message that is based on server side code (Tell me if a database update is successful). The event is called through AJAX using an RadAjaxPanel
- It needs to be modal.
- I need to be able to set the location where the window opens, so it does not show up behind the pdf.
- I need to be able to open the window on the server-side through AJAX

Thank you,
Blake
0
Svetlina Anati
Telerik team
answered on 30 Jul 2008, 11:42 AM
Hi B,

In this case I suggest to open the RadWindow from the server by executing a script, added to the ResponseScripts collection of the RadAjaxManager (RadAjaxPanel) you use for the ajax request as shown below:

protected void Button1_Click(object sender, EventArgs e)     
{     
    RadAjaxManager1.ResponseScripts.Add("radopen("http://www.google.com", null)");     
}    
 

It depends on you what will be the script you want to execute - showing radalert or RadWindow. I also recommend to examine this KB article.

In case this does not help, please provide a small, sample demo, which is fully working and shows a standard browser alert (or window via window.open) instead of RadWindow. In order to be able to attach files, you should open a new support ticket. Once I receive it, I will modify it in order to use RadWindow instead of standard browser popup.

All the best,
Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Alexandre
Top achievements
Rank 2
answered on 10 Dec 2009, 04:06 PM
Hi Svetlina this code work's for me fine, but using AJAX if the user click on my button the message appear ok but when he click again the message appear two times and again three time, how can I clear start up scripts before add a new one?

0
jai
Top achievements
Rank 1
answered on 11 Dec 2009, 08:49 AM
hi,

this code is working fine for me without any repeatation

radopen :

protected void Button2_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "RadAlertScript", "Sys.Application.add_load(function(){radopen('http://www.google.com');});", true);  
   
}

radalert:

protected void Button2_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "RadAlertScript", "Sys.Application.add_load(function(){radalert('test alert');});", true);  
   
}
0
sunitha
Top achievements
Rank 1
answered on 10 Nov 2010, 06:39 AM

 

Hi


Protected
Sub ViewLink_Click(ByVal sender As Object, ByVal e As System.EventArgs)

 

 

RadAjaxManager1.ResponseScripts.Add("radopen('TicketsMainView.aspx?Ticket_ID='" +  Label1.Text + "' ,'TicketListDialog')")

 

 

End Sub

this is not working for me

Please help me
 

Thanks
Sunitha

 

0
Svetlina Anati
Telerik team
answered on 11 Nov 2010, 03:45 PM
Hello guys,

 Alexandre, do you close the current RadWindow before you press the button again? If you do not, it is expected to show another RadWindow and you should modify your script accordingly. If you close the current RadWindow and after that you got more than one RadWindows when the button is clicked, please provide some fully runnable reproduction code because I was not able to reproduce the issue in the sample demo I prepared based on your explanations.

Sunitha, I am not sure why this approach does not work for you but different approach is needed for different scenarios as explained in the earlier provided article. Please, check it out and see what is your exact scenario and use the corresponding approach. In case you need further assistance, please share fully runnable reproduction code and we will do our best to help.

Kind regards,
Svetlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Gabe Silvarajoo
Top achievements
Rank 2
answered on 31 Oct 2012, 07:59 PM
Dear Telerik Support,

The script below works great for my application 

ScriptManager.RegisterStartupScript(Page, typeof(Page), "RadAlertScript", "Sys.Application.add_load(function(){radalert('test');});", true);

but how do you unload it after confirming the radalert prompt in code behind. Please advise. Thanks.
0
Gabe Silvarajoo
Top achievements
Rank 2
answered on 31 Oct 2012, 09:08 PM
Nevermind. I found a solution at Window / Alert, Prompt, Confirm

I use the following code:
RadWindowManager1.RadAlert("An error has occurred", 330, 100, "Error", string.Empty, string.Empty);
 in code behind. Works like a charm.
Tags
Window
Asked by
Mats
Top achievements
Rank 1
Answers by
jai
Top achievements
Rank 1
Svetlina Anati
Telerik team
Mats
Top achievements
Rank 1
Adam
Top achievements
Rank 1
Georgi Tunev
Telerik team
Vishal
Top achievements
Rank 1
B
Top achievements
Rank 1
Alexandre
Top achievements
Rank 2
sunitha
Top achievements
Rank 1
Gabe Silvarajoo
Top achievements
Rank 2
Share this question
or