First call of RadLightBox does not work

3 posts, 1 answers
  1. Nick
    Nick avatar
    9 posts
    Member since:
    Apr 2013

    Posted 15 Nov 2015 Link to this post

    Hello Telerik-Team,

    i have a RadLightBox with a ItemTemplate and a RadGrid with an asp:LinkButton, where i open the lightbox.

    Open the Lightbox is without any problems. I can change ​the Textbox Value in the RadLightBox Itemtemplate in PreRender. 

    But the problem is, in the first call is the Textbox in RadLightbox always empty. The calls after are working without any problems. 

    Any Ideas?

    Thanks,

    Nick

        function ShowBox(recordId) {
            $get('<%= HiddenField1.ClientID %>').value = recordId;
            var lightBox1 = $find('<%= RadLightBox1.ClientID %>');
            lightBox1.show();
    }

     

    <telerik:GridTemplateColumn HeaderText="<%$ Resources:Details %>" UniqueName="Details">
            <ItemTemplate>
                    <asp:LinkButton ID="lnkEdit" runat="server" Text="<%$ Resources:Details %>" ></asp:LinkButton>
               </ItemTemplate>
    </telerik:GridTemplateColumn>

     

    <telerik:RadLightBox ID="RadLightBox1" runat="server" Width="1000px" Height="720px"
        Modal="true" ZIndex="100000">
        <ClientSettings>
            <AnimationSettings HideAnimation="Resize" NextAnimation="Fade"
                PrevAnimation="Fade" ShowAnimation="Resize" />
        </ClientSettings>
        <Items>
            <telerik:RadLightBoxItem>
                <ItemTemplate>
                    <telerik:RadTextBox runat="server" ID="LightBoxNotice" Label="Notlar: "
                        text="" Width="800px" Height="300px" EnableViewState="false"
                        OnInit="LightBoxNotice_Init"
                        OnPreRender="LightBoxNotice_PreRender" TextMode="MultiLine"></telerik:RadTextBox>
                </ItemTemplate>
            </telerik:RadLightBoxItem>
        </Items>
    </telerik:RadLightBox>

  2. Nick
    Nick avatar
    9 posts
    Member since:
    Apr 2013

    Posted 15 Nov 2015 Link to this post

    Here is the PreRender Function:

     

    protected void LightBoxNotice_PreRender(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(HiddenField1.Value))
            return;
     
        var id = Convert.ToInt32(HiddenField1.Value);
     
        var item = DiskoMisko.FirstOrDefault(c => c.RecordId == id);
     
        ((RadTextBox)sender).Text = item.RecordNotice;
         
     
    }

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Kostadin
    Admin
    Kostadin avatar
    1713 posts

    Posted 18 Nov 2015 Link to this post

    Hi Nick,

    The problem is that initially when you load the page LightBoxNotice_PreRender is fired before ShowBox function. Generally the template is already initialize. A possible solution is to use a private property that will recreate the item template. Please check out the following code snippet.
    function ShowBox(recordId) {
        $get('<%= HiddenField1.ClientID %>').value = recordId;
        var lightBox1 = $find('<%= RadLightBox1.ClientID %>');
        lightBox1._items.getItem(0)._isRendered = false;
        lightBox1.show();
    }


    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top