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

Adding a html button to a Radwindow dynamically on the front end

2 Answers 267 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jesse
Top achievements
Rank 1
Veteran
Jesse asked on 23 May 2020, 03:56 PM

The code below works i the code behind but I need a rough equivalent doing this on the front end using js.

 

            RadWindow rw = new RadWindow();

          btn.Style.Add("position", "absolute");
            btn.Style.Add("bottom", "5px");
            btn.Style.Add("right", "10px");

 

         rw.ContentContainer.Controls.Add(btn);

 

 

 

Thanks in advance for any suggestions.

 

2 Answers, 1 is accepted

Sort by
0
Jesse
Top achievements
Rank 1
Veteran
answered on 25 May 2020, 11:11 AM

Now I am using the set_contentElement method to accomplish this- adding  multiple controls to the window dynamically

          var radWindow = $find("<%=RadWindowManager1.ClientID%>").Open(null,null);
            radWindow.setSize(640, 480);

          var btn = document.createElement("BUTTON");   // Create a <button> element
          var label = document.createElement("LABEL");
          var newDiv = document.createElement('div');

         label.className = "label";

          btn.className = "cbutton";

           newDiv.appendChild(btn);
           newDiv.appendChild(label);
          
           radWindow.set_contentElement(newDiv);

 

But if anyone knows a better method please post it.

 

0
Doncho
Telerik team
answered on 27 May 2020, 03:56 PM

Hi Jesse,

Thank you for sharing your solution!

Using the set_contentElement() is the correct approach to dynamically create and insert DOM elements in the RadWindow client-side. 

Another approach could be using predefined Controls or HTML elements inside the RadWindow. You can find it in the Using RadWindow as Controls Container article.

You can also find the Client-side API reference of the RadWindow Object here: https://docs.telerik.com/devtools/aspnet-ajax/controls/window/client-side-programming/radwindow-object

Concerning creating and appending HTML elements, It can be achieved in multiple ways. jQuery could be convenient for the case, see jQuery - Add Elements


Kind regards,
Doncho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Jesse
Top achievements
Rank 1
Veteran
Answers by
Jesse
Top achievements
Rank 1
Veteran
Doncho
Telerik team
Share this question
or