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

invoe radalert not thorugh buttonClick

11 Answers 229 Views
Window
This is a migrated thread and some comments may be shown as answers.
Hk
Top achievements
Rank 2
Hk asked on 24 Dec 2008, 04:14 PM
hi,
i want to simply invoke radAlert(msg) from script:
<script> 
function lala(){ 
msg="hey"
radalert(msg); 
</script> 
but it doesn't seem to work. is this the right way?


11 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 25 Dec 2008, 01:08 PM
Hi Hadar,

To invoke RadAlert or any of the other predefined RadWindows you must first add the RadWindowManager to your page and then you will be able to use them.
More details for predefined dialogs can be found here.

Sincerely yours,
Fiko
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hk
Top achievements
Rank 2
answered on 25 Dec 2008, 01:11 PM
Hi,
I have already defined a RadWindowManager:
<telerik:RadWindowManager id="RadWindowManager1" runat=server skin="Vista" EnableEmbeddedScripts="true"></telerik:RadWindowManager> 
before I made the question, therefore it remains..
0
GT
Top achievements
Rank 1
answered on 26 Dec 2008, 10:01 AM
Hi Hadar,

How do you call the lala() function? For example yu can try with <button onclick="lala(); return false;">test</button> - that should work.




Cheers,
Hulky
0
Fiko
Telerik team
answered on 26 Dec 2008, 02:17 PM
Hi Hadar,

The rovided code seems to be correct when you want to call radalert. I tested it and it is works as expected on my side. I am not sure what is your exact setup and how you call the function "lala()". For your convenience I attached a simple web page with my setup that you can use as start point.

I will describe logic of the project :
  • attach the showRadWindow() to the OnClientClick event in asp:Button declaration e.g. :
    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="showRadAlert(); return false;" /> 
  • insert "return false;" statement after attached showRadWindow() function. This prevents the postback when button is pressed.
  • implement the function e.g. :
    <script type="text/javascript"
       function showRadAlert() 
       { 
          var message = " RadAlert dialog"
          radalert(message); 
       } 
    </script> 
If you still experience the problem, please modify the attached project to demonstrate your setup, open a new support ticket and send it back to me. Once I receive it,  I will do my best to help.

Best wishes,
Fiko
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hk
Top achievements
Rank 2
answered on 28 Dec 2008, 08:30 AM
Hi Fiko,
As I mentioned, i'd like to invoke the method not thorugh a button click - I want the alert to be displayed as the page loads.
For some reason I get this error when I try to run your script (I've opened it as an AJAX 1.0 Enabled solution):

'~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager


This is what i meant:
 <script type="text/javascript">
        function showRadAlert()
        {
            var message = " RadAlert dialog";
            radalert(message);
        }
        showRadAlert();
    </script>





0
Shinu
Top achievements
Rank 2
answered on 29 Dec 2008, 07:24 AM
Hi Hadar,

RadScriptManager needs an HttpHandler to be declared in the application configuration file to operate properly. This can be done through the SmartTags of the control. Please open the page in Design mode. Click on the smart tag near on your RadScriptManager and choose Register Telerik.Web.UI.WebResource.axd. Check out the folowing link for more details.
RadScriptManager

Thanks,
Shinu.
0
Hk
Top achievements
Rank 2
answered on 29 Dec 2008, 07:45 AM
thanks,
yet my original question about invoking the radalert as I shown in my previous post, is not answered... :)
0
Shinu
Top achievements
Rank 2
answered on 29 Dec 2008, 08:25 AM
Hello Hadar,

I hope you want to display RadAlert when the page loads. You can try the below code snippet to show RadAlert on page load. ie, call the RadAlert from "pageLoad" function.

JavaScript:
<script type="text/javascript"
function pageLoad() 
    var message = " RadAlert dialog"
    radalert(message); 
</script> 

Thanks.
Shinu.
0
Hk
Top achievements
Rank 2
answered on 29 Dec 2008, 08:40 AM
Shinu,
not exactly, on server side I enable / disable the call to the "lala()" function. it means that sometimes
<script language="javascript"
lala(); 
</script> 
is rendered, according to server side issues, and sometimes it doesn't.

I will "patch" it and render a full pageLoad call, I just wondered why a simple call as aboce won't simply invoke as the page rendered and loaded.

Hadar
0
Georgi Tunev
Telerik team
answered on 29 Dec 2008, 02:46 PM
Hi Hadar,

The error message that you get is pretty self-explanatory. Did you follow the instructions in the error message?

As for showing radalert from the server, I believe that the following KB will be of help:
http://www.telerik.com/support/kb/aspnet-ajax/window/calling-radalert-from-codebehind-all-versions-of-radwindow.aspx

In addition, if you want to keep the client-side logic that you already use, you should call the function in the ASP.NET AJAX's pageLoad() event:
function pageLoad() 
    var message = " RadAlert dialog"
    radalert(message); 
 



All the best,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hk
Top achievements
Rank 2
answered on 06 Jan 2009, 12:15 PM
That won't work for me, because i have to wait untill several controls are loaded and read their text. If i try to do it on the pageload, the controls are still not loaded and they are null.

I just want the radalert simply invoke without any outer function! just as the script renders..
Tags
Window
Asked by
Hk
Top achievements
Rank 2
Answers by
Fiko
Telerik team
Hk
Top achievements
Rank 2
GT
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Georgi Tunev
Telerik team
Share this question
or