Infragistics Home

Infragistics Forums

Infragistics community online discussions.
Welcome to Infragistics Forums Sign in | FAQ
in Search

Adding Controls dynamically

Last post 09-02-2008 10:59 by skrile. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 08-29-2008 9:20

    • skrile
    • Not Ranked
    • Joined on 08-18-2008
    • Points 100

    Adding Controls dynamically

    I'm trying to add one test control on the server side to my WebDialogWindow and am having no luck.  I'm handling the "showing" of the modal on a Row Command event from a grid view.  Here are the relavent bits:

     

    {BUTTON on Grid}

        <asp:ImageButton ID="GridBtn"
        runat="server"
        CommandArgument='<%#Eval("MajorBrainstormID") %>'
        CommandName="display"
        ImageUrl="~/img/blankgrid.png" />

     {CODE}

        Public Sub BrainstormGrid_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles PriorityGrid.RowCommand
            If (e.CommandName = "display") Then
                Dim btn As New Label
                btn.Text = "test"

                Dim dialog As WebDialogWindow = TryCast(PriorityGridModal, WebDialogWindow)

                With dialog
                    .ContentPane.Controls.Add(btn)
                    .WindowState = Infragistics.Web.UI.LayoutControls.DialogWindowState.Normal
                End With

                gridUpdatePanel.Update()

            End If
        End Sub

     

     

    {CONTROL on .aspx page}

            <asp:UpdatePanel runat="server" ID="gridUpdatePanel" UpdateMode="Conditional">
                <ContentTemplate>
                    <ig:WebDialogWindow
                        ID="PriorityGridModal"
                        runat="server"
                        Height="300px"
                        Width="400px" Modal="True"
                        Moveable="true"
                        Top="0px"
                        Left="0px"
                        WindowState="Hidden"
                        CssClass="modalContainer"
                        >
                        <ContentPane>
                            <Template>
                                                                               
                            </Template>
                        </ContentPane>
                    </ig:WebDialogWindow> 
                </ContentTemplate>
            </asp:UpdatePanel>

     

     

    The DialogWindow displays just fine, but it is empty.  Can't seem to work out why.  I'm not getting any errors, and I've stepped through the execution and everything is firing as expected.  What am I missing?

    • Post Points: 20
  • 09-01-2008 10:06 In reply to

    Re: Adding Controls dynamically

    Hello,

    Thanks for the detailed description of the problem. I believe the solution here is to add controls to the TemplateControl object of the ContentPane, as opposed to the ContentPane directly. I have just tried this and it works great: 

            Label l = new Label();
            l.Text = "GGGGGG";
            WebDialogWindow1.ContentPane.TemplateControl.Controls.Add(l);

    Please, let me know if this helps. 

    Best Regards,
    Rumen Stankov (MCSD.NET)
    The Infragistics ASP.NET Team
    • Post Points: 20
  • 09-02-2008 10:59 In reply to

    • skrile
    • Not Ranked
    • Joined on 08-18-2008
    • Points 100

    Re: Adding Controls dynamically

    Hmmm....well, it doesn't really work.

     I stripped away the nonsense, and left us with just a simple working modal:

     {.aspx page}

    <asp:Button Text="Show Modal" runat="server" ID="showBtn" OnClick="showModal" />

    <ig:WebDialogWindow
    ID="WebDialogWindow1" runat="server" Height="300px" Width="400px"
    Modal="true"
    Moveable="true"
    WindowState="Hidden"
    ModalBackgroundCssClass="modalBackground">
       <ContentPane>
          <Template></Template>
       </ContentPane>
    </ig:WebDialogWindow>

    {.aspx.vb code}

    Public Sub showModal(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim lbl As New Label
       lbl.Text =
    "Hi there"
       WebDialogWindow1.ContentPane.TemplateControl.Controls.Add(lbl)
       WebDialogWindow1.WindowState = Infragistics.Web.UI.LayoutControls.DialogWindowState.Normal
    End Sub

     So, the code "works" in that a label is added...but it is added to my page, not the modal (appears outside the modal on the page behind.  Do I have to create a "named" template or something?

    • Post Points: 5
Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems