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

Button to download file on ToopTip

1 Answer 95 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Jaime
Top achievements
Rank 1
Jaime asked on 12 Dec 2012, 08:41 PM
Hi,
I used this example DEMO, in the ProductDetailsCS.ascx I'd put a button to download a file save in server's folder and save filename on DB, but when click on button show me this error: "Error en tiempo de ejecución de Microsoft JScript: Sys.WebForms.PageRequestManagerParserErrorException: No se pudo analizar el mensaje recibido del servidor. Este error suele producirse cuando la respuesta resulta modificada por llamadas a Response.Write() o cuando los filtros de respuesta, los HttpModules o el seguimiento de servidor están habilitados.
Detalles: Error de análisis cerca de 'PK"

Code Button to Download is
protected void Descargar_Click(object sender, EventArgs e)
        {
            string filePath = ((Label)FormView1.FindControl("DocumentoConvocatoriaLabel")).Text;
            string archivo = "~/DocsGC/"+filePath;
            Response.Clear();
            Response.ContentType = "application/vnd.ms-excel, application/pdf, application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=\"" + archivo + "\"");
            Response.Flush();
            Response.TransmitFile(Server.MapPath(archivo));
            Response.End();
        }
Then my FormView on usercontrol:
<asp:FormView ID="FormView1" runat="server" DataKeyNames="IDGC"
    DataSourceID="SqlDataSourceFormView1" style="text-align: center">
    <EditItemTemplate>
        Convocatoria:
        <asp:TextBox ID="ConvocatoriaTextBox" runat="server"
            Text='<%# Bind("Convocatoria") %>' />
        <br />
        IDGC:
        <asp:Label ID="IDGCLabel1" runat="server" Text='<%# Eval("IDGC") %>' />
        <br />
        AreaConvocatoria:
        <asp:TextBox ID="AreaConvocatoriaTextBox" runat="server"
            Text='<%# Bind("AreaConvocatoria") %>' />
        <br />
        MontoFina:
        <asp:TextBox ID="MontoFinaTextBox" runat="server"
            Text='<%# Bind("MontoFina") %>' />
        <br />
        MontoFinaHasta:
        <asp:TextBox ID="MontoFinaHastaTextBox" runat="server"
            Text='<%# Bind("MontoFinaHasta") %>' />
        <br />
        TipoDinero:
        <asp:TextBox ID="TipoDineroTextBox" runat="server"
            Text='<%# Bind("TipoDinero") %>' />
        <br />
        Cambio:
        <asp:TextBox ID="CambioTextBox" runat="server" Text='<%# Bind("Cambio") %>' />
        <br />
        Duracion:
        <asp:TextBox ID="DuracionTextBox" runat="server"
            Text='<%# Bind("Duracion") %>' />
        <br />
        PlazoConvocatoria:
        <asp:TextBox ID="PlazoConvocatoriaTextBox" runat="server"
            Text='<%# Bind("PlazoConvocatoria") %>' />
        <br />
        PlazoEnvio:
        <asp:TextBox ID="PlazoEnvioTextBox" runat="server"
            Text='<%# Bind("PlazoEnvio") %>' />
        <br />
        ModoEnvio:
        <asp:TextBox ID="ModoEnvioTextBox" runat="server"
            Text='<%# Bind("ModoEnvio") %>' />
        <br />
        Contraparte:
        <asp:TextBox ID="ContraparteTextBox" runat="server"
            Text='<%# Bind("Contraparte") %>' />
        <br />
        ObjetivosConv:
        <asp:TextBox ID="ObjetivosConvTextBox" runat="server"
            Text='<%# Bind("ObjetivosConv") %>' />
        <br />
        TemasPrio:
        <asp:TextBox ID="TemasPrioTextBox" runat="server"
            Text='<%# Bind("TemasPrio") %>' />
        <br />
        AsociosRequeridos:
        <asp:TextBox ID="AsociosRequeridosTextBox" runat="server"
            Text='<%# Bind("AsociosRequeridos") %>' />
        <br />
        Elegibilidad:
        <asp:TextBox ID="ElegibilidadTextBox" runat="server"
            Text='<%# Bind("Elegibilidad") %>' />
        <br />
        Idioma:
        <asp:TextBox ID="IdiomaTextBox" runat="server" Text='<%# Bind("Idioma") %>' />
        <br />
        Observaciones:
        <asp:TextBox ID="ObservacionesTextBox" runat="server"
            Text='<%# Bind("Observaciones") %>' />
        <br />
        DocumentoConvocatoria:
        <asp:TextBox ID="DocumentoConvocatoriaTextBox" runat="server"
            Text='<%# Bind("DocumentoConvocatoria") %>' />
        <br />
        FechaRegistro:
        <asp:TextBox ID="FechaRegistroTextBox" runat="server"
            Text='<%# Bind("FechaRegistro") %>' />
        <br />
        Donante:
        <asp:TextBox ID="DonanteTextBox" runat="server" Text='<%# Bind("Donante") %>' />
        <br />
        Estado:
        <asp:TextBox ID="EstadoTextBox" runat="server" Text='<%# Bind("Estado") %>' />
        <br />
        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
            CommandName="Update" Text="Actualizar" />
         <asp:LinkButton ID="UpdateCancelButton" runat="server"
            CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
    </EditItemTemplate>
    <InsertItemTemplate>
        Convocatoria:
        <asp:TextBox ID="ConvocatoriaTextBox" runat="server"
            Text='<%# Bind("Convocatoria") %>' />
        <br />
 
        AreaConvocatoria:
        <asp:TextBox ID="AreaConvocatoriaTextBox" runat="server"
            Text='<%# Bind("AreaConvocatoria") %>' />
        <br />
        MontoFina:
        <asp:TextBox ID="MontoFinaTextBox" runat="server"
            Text='<%# Bind("MontoFina") %>' />
        <br />
        MontoFinaHasta:
        <asp:TextBox ID="MontoFinaHastaTextBox" runat="server"
            Text='<%# Bind("MontoFinaHasta") %>' />
        <br />
        TipoDinero:
        <asp:TextBox ID="TipoDineroTextBox" runat="server"
            Text='<%# Bind("TipoDinero") %>' />
        <br />
        Cambio:
        <asp:TextBox ID="CambioTextBox" runat="server" Text='<%# Bind("Cambio") %>' />
        <br />
        Duracion:
        <asp:TextBox ID="DuracionTextBox" runat="server"
            Text='<%# Bind("Duracion") %>' />
        <br />
        PlazoConvocatoria:
        <asp:TextBox ID="PlazoConvocatoriaTextBox" runat="server"
            Text='<%# Bind("PlazoConvocatoria") %>' />
        <br />
        PlazoEnvio:
        <asp:TextBox ID="PlazoEnvioTextBox" runat="server"
            Text='<%# Bind("PlazoEnvio") %>' />
        <br />
        ModoEnvio:
        <asp:TextBox ID="ModoEnvioTextBox" runat="server"
            Text='<%# Bind("ModoEnvio") %>' />
        <br />
        Contraparte:
        <asp:TextBox ID="ContraparteTextBox" runat="server"
            Text='<%# Bind("Contraparte") %>' />
        <br />
        ObjetivosConv:
        <asp:TextBox ID="ObjetivosConvTextBox" runat="server"
            Text='<%# Bind("ObjetivosConv") %>' />
        <br />
        TemasPrio:
        <asp:TextBox ID="TemasPrioTextBox" runat="server"
            Text='<%# Bind("TemasPrio") %>' />
        <br />
        AsociosRequeridos:
        <asp:TextBox ID="AsociosRequeridosTextBox" runat="server"
            Text='<%# Bind("AsociosRequeridos") %>' />
        <br />
        Elegibilidad:
        <asp:TextBox ID="ElegibilidadTextBox" runat="server"
            Text='<%# Bind("Elegibilidad") %>' />
        <br />
        Idioma:
        <asp:TextBox ID="IdiomaTextBox" runat="server" Text='<%# Bind("Idioma") %>' />
        <br />
        Observaciones:
        <asp:TextBox ID="ObservacionesTextBox" runat="server"
            Text='<%# Bind("Observaciones") %>' />
        <br />
        DocumentoConvocatoria:
        <asp:TextBox ID="DocumentoConvocatoriaTextBox" runat="server"
            Text='<%# Bind("DocumentoConvocatoria") %>' />
        <br />
        FechaRegistro:
        <asp:TextBox ID="FechaRegistroTextBox" runat="server"
            Text='<%# Bind("FechaRegistro") %>' />
        <br />
        Donante:
        <asp:TextBox ID="DonanteTextBox" runat="server" Text='<%# Bind("Donante") %>' />
        <br />
        Estado:
        <asp:TextBox ID="EstadoTextBox" runat="server" Text='<%# Bind("Estado") %>' />
        <br />
        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
            CommandName="Insert" Text="Insertar" />
         <asp:LinkButton ID="InsertCancelButton" runat="server"
            CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
    </InsertItemTemplate>
    <ItemTemplate>
        <table align="center" border="1" class="style2" frame="box">
            <tr>
                <td colspan="2">
                    Convocatoria:
                    <br />
                    <strong>
                    <asp:Label ID="ConvocatoriaLabel" runat="server" CssClass="style1"
                        Text='<%# Bind("Convocatoria") %>' />
                    </strong>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    Código Convocatoria:
                    <br />
                    <asp:Label ID="IDGCLabel" runat="server"
                        style="color: #FFFFFF; font-weight: 700" Text='<%# Eval("IDGC") %>' />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                     </td>
            </tr>
            <tr>
                <td>
                    Donante:</td>
                <td style="text-align: justify">
                    <b>
                    <asp:Label ID="DonanteLabel" runat="server" CssClass="style3"
                        style="text-align: justify" Text='<%# Bind("Donante") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    AreaConvocatoria:</td>
                <td>
                    <b>
                    <asp:Label ID="AreaConvocatoriaLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("AreaConvocatoria") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    MontoFina:</td>
                <td>
                    <b>
                    <asp:Label ID="MontoFinaLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("MontoFina") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    MontoFinaHasta:</td>
                <td>
                    <b>
                    <asp:Label ID="MontoFinaHastaLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("MontoFinaHasta") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    TipoDinero:</td>
                <td>
                    <b>
                    <asp:Label ID="TipoDineroLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("TipoDinero") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    Cambio:</td>
                <td>
                    <b>
                    <asp:Label ID="CambioLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("Cambio") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    Duracion:</td>
                <td>
                    <b>
                    <asp:Label ID="DuracionLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("Duracion") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    PlazoConvocatoria:</td>
                <td>
                    <b>
                    <asp:Label ID="PlazoConvocatoriaLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("PlazoConvocatoria", "{0:dd/MM/yyyy}") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    PlazoEnvio:</td>
                <td>
                    <b>
                    <asp:Label ID="PlazoEnvioLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("PlazoEnvio", "{0:dd/MM/yyyy}") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    ModoEnvio:</td>
                <td>
                    <b>
                    <asp:Label ID="ModoEnvioLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("ModoEnvio") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    Contraparte:</td>
                <td>
                    <b>
                    <asp:Label ID="ContraparteLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("Contraparte") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    ObjetivosConv:</td>
                <td>
                    <b>
                    <asp:Label ID="ObjetivosConvLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("ObjetivosConv") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    TemasPrio:</td>
                <td>
                    <b>
                    <asp:Label ID="TemasPrioLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("TemasPrio") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    AsociosRequeridos:</td>
                <td>
                    <b>
                    <asp:Label ID="AsociosRequeridosLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("AsociosRequeridos") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    Elegibilidad:</td>
                <td>
                    <b>
                    <asp:Label ID="ElegibilidadLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("Elegibilidad") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    Idioma:</td>
                <td>
                    <b>
                    <asp:Label ID="IdiomaLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("Idioma") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    Observaciones:
                </td>
                <td>
                    <b>
                    <asp:Label ID="ObservacionesLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("Observaciones") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td>
                    DocumentoConvocatoria:</td>
                <td>
                    <b>
                    <asp:Label ID="DocumentoConvocatoriaLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("DocumentoConvocatoria") %>' />
                    <br />
                    </b>
                    <asp:Button ID="Descargar" runat="server" onclick="Descargar_Click"
                        Text="Descargar" />
                </td>
            </tr>
            <tr>
                <td>
                    FechaRegistro:</td>
                <td>
                    <b>
                    <asp:Label ID="FechaRegistroLabel" runat="server" CssClass="style3"
                        Text='<%# Bind("FechaRegistro", "{0:dd/MM/yyyy}") %>' />
                    </b>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                     </td>
            </tr>
            <tr>
                <td colspan="2">
                    Estado:
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: justify">
                    <asp:Label ID="EstadoLabel" runat="server"
                        style="font-weight: 700; color: #FFFFFF" Text='<%# Bind("Estado") %>' />
                </td>
            </tr>
        </table>
 
    </ItemTemplate>
</asp:FormView>
Any Idea??
Thanks.

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 14 Dec 2012, 11:59 AM
Hello Jaime,

The user control loaded in the tooltip is actually loaded in an ASP UpdatePanel. This means you cannot download a file like this from the server cilck handler, because the response from the server is not the full response needed to do this, it is a partial page update.

What I can suggest is executing a JavaScript function that will open the URL you have in a new browser window (or in the same) - see window.open(url) or window.location = url. How to execute a script is explained in this help article - the ScriptManager.RegisterStartupScript() method is perhaps the most robust one.


Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ToolTip
Asked by
Jaime
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or