Welcome Guest Search | Active Topics | Sign In | Register

asp PlaceHolder section inside UpdatePanel not showing in PDF after ASPXToPDF Conversion Options
Tyler
Posted: Friday, July 12, 2013 5:53:32 PM
Rank: Member
Groups: Member

Joined: 7/11/2013
Posts: 11
I have an UpdatePanel containing a ComboBox and a RadTextBox as shown in the code below. I am using the PlaceHolder to make that entire table visible/invisible depending on which combobox item is selected. The PlaceHolder's Visible property is set to "false" in the codebehind when the form loads. I am also using ASPXToPDF to convert my aspx file to a PDF after all fields are filled, radio buttons selected, etc. In the PDF, the PlaceHolder section does not appear when it is set to "visible" before submission. Should I be using something else instead of the UpdatePanel or the PlaceHolder?

Code: HTML/ASPX
<asp:UpdatePanel ID="updatepanel1" runat="server" RenderMode="Block" UpdateMode="Conditional">
        <ContentTemplate>
            <table align="center" width="1089px">
                <tr>
                    <td>
                        <asp:ComboBox ID="cb1" runat="server" AutoPostBack="true" 
                            onselectedindexchanged="cb1_SelectedIndexChanged1">
                            <asp:ListItem Value="Item1" Text="Item1"></asp:ListItem>
                            <asp:ListItem Value="Item2" Text="Item2"></asp:ListItem> 
                    </td>
                </tr>
            </table>
            <asp:PlaceHolder ID="PlaceHolder1" runat="server">
                <table align="center" width="1089px">
                    <tr>
                        <td>
                            Text:
                        </td>
                        <td>
                            <telerik:RadTextBox ID="RadTextBox1" runat="server"></telerik:RadTextBox>
                        </td>
                    </tr>
                </table>
            </asp:PlaceHolder>
        </ContentTemplate>
</asp:UpdatePanel>


Codebehind (C#):

Code: C#
protected void cb1_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (cb1.SelectedValue == "Item2")
            {
                PlaceHolder1.Visible = true;
            }
            else
            {
                
                PlaceHolder1.Visible = false;
            }
        }
eo_support
Posted: Friday, July 12, 2013 6:27:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

We tested your code with standard asp:ListBox and it works fine. Below is our full test code:

Code: HTML/ASPX
<form runat="server" id="form1">
    <asp:ScriptManager runat="server" ID="sm1"></asp:ScriptManager>
    <eo:ASPXToPDF runat="server" ID="ASPXToPDF1"></eo:ASPXToPDF>
    <asp:Button runat="server" ID="Button1" Text="Test" onclick="Button1_Click" />
    <asp:UpdatePanel ID="updatepanel1" runat="server" RenderMode="Block" UpdateMode="Conditional">
        <ContentTemplate>
            <table align="center" width="1089px">
                <tr>
                    <td>
                        <asp:ListBox ID="cb1" runat="server" AutoPostBack="true" 
                            onselectedindexchanged="cb1_SelectedIndexChanged1">
                            <asp:ListItem Value="Item1" Text="Item1">
                            </asp:ListItem>
                            <asp:ListItem Value="Item2" Text="Item2">
                            </asp:ListItem>
                        </asp:ListBox>
                    </td>
                </tr>
            </table>
            <asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible=false>
                <table align="center" width="1089px">
                    <tr>
                        <td>
                            Text:
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
            </asp:PlaceHolder>
        </ContentTemplate>
    </asp:UpdatePanel>
</form>


Code: C#
protected void cb1_SelectedIndexChanged1(object sender, EventArgs e)
{
    if (cb1.SelectedValue == "Item2")
    {
        PlaceHolder1.Visible = true;
    }
    else
    {

        PlaceHolder1.Visible = false;
    }
}

protected void Button1_Click(object sender, EventArgs e)
{
    ASPXToPDF1.RenderAsPDF();
}


The basic rule for ASPXToPDF is: It renders what you see on screen as if ASPXToPDF1.RenderAsPDF was not called. In the above code, if you comment out the call inside Button1_Click, then the page will be rendered on screen with the place holder section visible (assuming you have selected "Item 2" before clicking "Test" button), so in this case it will be visible in the PDF file as well.

However if you have made certain changes on the client side that is NOT submitted back to the server side, then when you click the "Test" button, those changes would be lost and when the page reloads in the browser, it would not reflect those changes. In this case if you call RenderAsPDF, those changes won't appear in the PDF file either. In another word, the same rule applies: If it doesn't show up in the browser when RenderAsPDF is not called, it won't show up in the PDF file when RenderAsPDF is called.

Hope this helps. Feel free to let us know if you still have problems.

Thanks!
Tyler
Posted: Monday, July 15, 2013 9:02:18 AM
Rank: Member
Groups: Member

Joined: 7/11/2013
Posts: 11
Should I try something besides the ComboBox then? Maybe a RadioButtonList or a DropDown?
eo_support
Posted: Monday, July 15, 2013 9:07:21 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

They should all work.

Thanks!
Tyler
Posted: Monday, July 15, 2013 9:26:16 AM
Rank: Member
Groups: Member

Joined: 7/11/2013
Posts: 11
I think I found the problem. In codebehind on page load I was setting the placeholder's visible property to false and after removing that the pdf conversion worked fine. I set it to false in the aspx instead. Thank you for your help!
eo_support
Posted: Monday, July 15, 2013 9:27:51 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Great. Glad that you found the problem!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.