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

RadAlert from User Control

3 Answers 101 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 24 Nov 2009, 09:31 PM
I have a simple user control (.ascx) that will contain an <asp:ImageButton> control. I would like to expose a property of the control (i.e. message that will be displayed in the alert) and then when the user clicks on the image button, have the radalert display the message that was set in the property.

Any thoughts?

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Nov 2009, 11:13 AM
Hi Dennis,

You can call the radalert from code behind and pass the property value as alert message. Here is the code that I tried.

CS (in ascx):
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        Name = "Telerik"
    } 
    private string _Name; 
    public string Name 
    { 
        get 
        { 
            return _Name; 
        } 
        set 
        { 
            _Name = value; 
        } 
    }  
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        string radalertscript = "<script language='javascript'>function f(){radalert('" + Name + "', 330, 210); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>"
        Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);  
    } 
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e) 
    { 
        string radalertscript = "<script language='javascript'>function f(){radalert('" + Name + "', 330, 210); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>"
        Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", radalertscript);  
    } 

Thanks,
Princy.
0
Georgi Tunev
Telerik team
answered on 25 Nov 2009, 12:36 PM
Hello Dennis,

In addition to Princy's reply, I would also suggest to check this blog post:
http://blogs.telerik.com/blogs/09-05-05/executing_javascript_function_from_server-side_code.aspx



Sincerely yours,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dennis
Top achievements
Rank 1
answered on 25 Nov 2009, 04:51 PM
That worked like a charm!  Thanks for the help.

Georgi, thank you for the link as well.

Dennis
Tags
Window
Asked by
Dennis
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Georgi Tunev
Telerik team
Dennis
Top achievements
Rank 1
Share this question
or