RadAlert Mutliple Alerts with Buttons

2 posts, 0 answers
  1. Danny
    Danny avatar
    22 posts
    Member since:
    Jan 2009

    Posted 07 Aug Link to this post

    I am trialing RadDesktopAlert for a new system I am developing, and considering purchasing radcontrol for WinForms. I have used RadControls for the web before. 

     

    I have created a RadDesktopAlert and it appears to work quit well. I create the RadDesktopAlert in code and added 2 buttons behind it. I can run code from those buttons without any issues. However I need to pass an ID into the RadDesktopAlert , that I can access when pressing these buttons. 

     

    Is there a way I can pass a variable, does as a unique string into the RadDesktopAlert that I can read when pressing one of these buttons?

     

    Many Thanks

     

     

     

            private void rbeRequest_Click(object sender, EventArgs e)
            {
                Console.WriteLine("code test here");
                // I need to get a value specific to the rad alert here. 
            }

     

     

     

          // create the RadDesktopAlert
                RadDesktopAlert radDA = new RadDesktopAlert();
               

                    //declare the buttons. 
                    RadButtonElement rbeRequest = new RadButtonElement();
                    RadButtonElement rbeAdministrator = new RadButtonElement();

                    rbeRequest.Name = "test1";
                  
                    //assign code to each button that runs. 
                    rbeRequest.Click += rbeRequest_Click;
                    rbeAdministrator.Click += rbeAdministrator_Click;

                   
                    
                    //set padding around the buttons to make them a little bigger. 
                    rbeAdministrator.Padding = new System.Windows.Forms.Padding(5);
                    rbeRequest.Padding = new System.Windows.Forms.Padding(5);

                    //apply a lable to the buttons
                    rbeAdministrator.Text = "My Administrator is Present";
                    rbeRequest.Text = "Request Permission";

                    //add the buttons to the DesktopAlert component. 
                    radDA.ButtonItems.AddRange(new Telerik.WinControls.RadItem[] {
                    rbeRequest,
                    rbeAdministrator});
                }

                //apply text. 
                radDA.CaptionText = "caption text goes here";
                radDA.ContentText = "content text goes here"   ;
            
                //show the alert. 
                radDA.Show();
            }

  2. Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 08 Aug Link to this post

    Hello Danny,

    You can use the Tag property of the alert's popup. For example, you can set it like this:
    RadDesktopAlert radDA = new RadDesktopAlert();
    radDA.Popup.Tag = "MyID";

    Then you can get in in the event handler:
    private void rbeRequest_Click(object sender, EventArgs e)
    {
        var button = sender as RadButtonElement;
        var popup  = button.ElementTree.Control as DesktopAlertPopup;
        var id = popup.Tag;
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top