RadAlert from User Control

4 posts, 1 answers
  1. Dennis
    Dennis avatar
    23 posts
    Member since:
    Nov 2008

    Posted 24 Nov 2009 Link to this post

    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?
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Nov 2009 Link to this post

    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.
  3. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 25 Nov 2009 Link to this post

    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.
  4. Dennis
    Dennis avatar
    23 posts
    Member since:
    Nov 2008

    Posted 25 Nov 2009 Link to this post

    That worked like a charm!  Thanks for the help.

    Georgi, thank you for the link as well.

    Dennis
Back to Top