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

First call of RadLightBox does not work

2 Answers 60 Views
LightBox
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 15 Nov 2015, 06:48 PM

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 Answers, 1 is accepted

Sort by
0
Nick
Top achievements
Rank 1
answered on 15 Nov 2015, 06:50 PM

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;
     
 
}

0
Accepted
Kostadin
Telerik team
answered on 18 Nov 2015, 01:01 PM
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
Tags
LightBox
Asked by
Nick
Top achievements
Rank 1
Answers by
Nick
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or