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

reach the event of Dynamic Control into RadWindow

2 Answers 16 Views
Window
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 24 Jul 2014, 08:23 AM
Hello,

I'm working on a project that has a RadWindow.
I have added controls dynamically inside the RadWindow.
I try to close the RadWindow by clicking on a button that is located inside the RadWindow.
However, code execution doesn’t reach the button clicking event.

VB.NET:
Dim btn_PopupAccept1 As New Button()
    
  
    Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
        With btn_PopupAccept1
            .Text = "Accept"
        End With
  
  
        AddHandler btn_PopupAccept1.Click, AddressOf btn_PopupAccept1_Click
   
    End Sub
 
    Protected Sub RadTreeView1_NodeClick(sender As Object, e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeView1.NodeClick
        Dim myLabel As Label = New Label()
        Dim myTextBox As TextBox = New TextBox()
        Dim myRadio As RadioButton = New RadioButton()
        Dim myCheckBox As CheckBox = New CheckBox()
        Dim spacer As LiteralControl = New LiteralControl(" ")
        Dim br As LiteralControl = New LiteralControl("<br />")
        Dim DivStart As LiteralControl = New LiteralControl("<div style=""padding:15px;""")
        Dim DivEnd As LiteralControl = New LiteralControl("</div>")
        myLabel.Text = "Control " & e.Node.Text
        myLabel.ID = "lbl_PopupControl" & e.Node.Value
        myTextBox.TextMode = TextBoxMode.Number
        myTextBox.ToolTip = "numeric"
  
        RadWindow1.VisibleOnPageLoad = True
        RadWindow1.ID = "RadWindow1"
        RadWindow1.Width = 500
        RadWindow1.Height = 300
        RadWindow1.Modal = True
        RadWindow1.CenterIfModal = True
  
        RadWindow1.ContentContainer.Controls.Add(DivStart)
  
        RadWindow1.ContentContainer.Controls.Add(myLabel)
        RadWindow1.ContentContainer.Controls.Add(spacer)
        RadWindow1.ContentContainer.Controls.Add(myTextBox)
  
        RadWindow1.ContentContainer.Controls.Add(br)
        RadWindow1.ContentContainer.Controls.Add(btn_PopupAccept1)
        RadWindow1.ContentContainer.Controls.Add(DivEnd)
  
    End Sub
 
    Protected Sub btn_PopupAccept1_Click(sender As Object, e As EventArgs)
  
        Dim script As String
    End Sub


ASPX:
<table cellpadding="0" cellspacing="0" class="auto-style1">
            <tr>
                <td class="auto-style2">
                    <telerik:RadTreeView ID="RadTreeView1" Runat="server">
                    </telerik:RadTreeView>
                </td>
                <td>
                     
                    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
                    </telerik:RadWindowManager>
  
               
  
                    <telerik:RadWindow ID="RadWindow1" runat="server">
                      
                    </telerik:RadWindow>
                </td>
            </tr>
        </table>


How can I accomplish this??

Thanks,
Daniel.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 24 Jul 2014, 09:32 AM
Hi Daniel,

The dynamically created controls should not persist after a postback. Please note that ASP.NET do not recreate the dynamic controls and you should recreate them. Please do the following modification in your VB code which works fine at my end.

VB:
Private btn_PopupAccept1 As New Button()
Private myLabel As New Label()
Private myTextBox As New TextBox()
Private myRadio As New RadioButton()
Private myCheckBox As New CheckBox()
Private spacer As New LiteralControl(" ")
Private br As New LiteralControl("<br />")
Private DivStart As New LiteralControl("<div style=""padding:15px;""")
Private DivEnd As New LiteralControl("</div>")
Private Sub Page_Init(sender As Object, e As EventArgs)
    myTextBox.TextMode = TextBoxMode.SingleLine
    myTextBox.ToolTip = "numeric"
    myTextBox.AutoPostBack = True
 
    btn_PopupAccept1.ID = "btn_PopupAccept1"
    btn_PopupAccept1.Text = "Accept"
    btn_PopupAccept1.Click += New EventHandler(AddressOf btn_PopupAccept1_Click)
 
    RadWindow1.ContentContainer.Controls.Add(DivStart)
    RadWindow1.ContentContainer.Controls.Add(myLabel)
    RadWindow1.ContentContainer.Controls.Add(spacer)
    RadWindow1.ContentContainer.Controls.Add(myTextBox)
    RadWindow1.ContentContainer.Controls.Add(br)
    RadWindow1.ContentContainer.Controls.Add(btn_PopupAccept1)
    RadWindow1.ContentContainer.Controls.Add(DivEnd)
End Sub
 
Protected Sub RadTreeView1_NodeClick(sender As Object, e As Telerik.Web.UI.RadTreeNodeEventArgs)
    myLabel.Text = "Control " + e.Node.Text
    myLabel.ID = "lbl_PopupControl" + e.Node.Value
    RadWindow1.VisibleOnPageLoad = True
    RadWindow1.Width = 500
    RadWindow1.Height = 300
    RadWindow1.Modal = True
    RadWindow1.CenterIfModal = True
End Sub
Protected Sub btn_PopupAccept1_Click(sender As Object, e As EventArgs)
    'your code
End Sub

Thanks,
Shinu.
0
Daniel
Top achievements
Rank 1
answered on 27 Jul 2014, 08:03 AM
Hi Shinu,

Thank you very much, it works!!!

Just a little note:
The equivalent of :
btn_PopupAccept1.Click += new EventHandler(btn_PopupAccept1_Click);

in VB is:
AddHandler btn_PopupAccept1.Click, AddressOf btn_PopupAccept1_Click


Thanks,

Daniel.
Tags
Window
Asked by
Daniel
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Share this question
or