Bonjour,

J'utilise cette procédure dans mon code behind pour faire l'export d'un gridview vers l'excel:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 Protected Sub Export(ByVal sender As Object, ByVal e As System.EventArgs)
 
        GridView1.HeaderStyle.BackColor = Drawing.Color.White
        GridView1.GridLines = GridLines.Both
        Response.Clear()
        Response.AddHeader("content-disposition", "attachment;filename=Liste_detaillee_Indicateur.xls")
        Response.Charset = ""
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        Response.ContentType = "application/vnd.xls"
        Dim stringWrite As New System.IO.StringWriter
        Dim htmlWrite As New HtmlTextWriter(stringWrite)
        GridView1.RenderControl(htmlWrite)
        Response.Write(stringWrite.ToString())
        Response.End()
 
    End Sub
 
 Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
 
    End Sub
J'ai besoin de faire appel à une fonction javascript dans ce code, donc j'ai ajouté cette ligne en haut:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
ScriptManager.RegisterStartupScript(Me.Page, Page.GetType(), "ScripAffichage", "alerte('ok');", True)
mais rien ne se passe.

Saviez vous comment résoudre ce problème?

Par avance merci