IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

ASPX problème accent dans URL


Sujet :

ASP.NET

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 33
    Points : 24
    Points
    24
    Par défaut ASPX problème accent dans URL
    Salut à tous .
    Je viens de créer un site ASP qui tourne correctement a part les liens URL comportant des accent.

    Dans firefox, le lien est corrctement traduit mais le lien File://....... ne fonctionne pas --> PB connu de firefox

    Dans IE, les accent é sont traduit en é et les accent è en è

    Exemple

    Assurance Qualité\Hygiène-Sécurité\test.xls

    J'ai besoin d'ouvrir ces fichiers qui se situe sur un partage réseau.

    Je ne sais pas comment résoudre ces problèmes d'accent.
    Pouvez vous me dire comment avoir correctement les lien URL avec accent selon le navigateur utilisé.

    Voici la source de la page Default.aspx
    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
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    <%@ Page Title="Page d'accueil" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeFile="Default.aspx.vb" Inherits="_Default"%>
     
     
     
    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    </asp:Content>
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <h2>
    		Bienvenue dans ASP.NET!
    	</h2>
    	<p>
    		<asp:DropDownList ID="SelectCategorie" runat="server" AutoPostBack="True" 
    			DataSourceID="SqlCategorie" DataTextField="categorie" 
    			DataValueField="categorie">
    		</asp:DropDownList>
    		<asp:DropDownList ID="SelectType" runat="server" AutoPostBack="True" 
    			DataSourceID="SqlType" DataTextField="type" DataValueField="type">
    		</asp:DropDownList>
    &nbsp;<asp:HyperLink ID="HyperLink1" runat="server" ImageUrl="~/images/oeil.gif"></asp:HyperLink>
    		<asp:ImageButton ID="modif" runat="server" Height="21px" 
    			ImageUrl="~/images/ModifEnregistrement.jpg" Width="26px" />
    	    <asp:TextBox ID="TextBox1" runat="server" Width="502px"></asp:TextBox>
    	</p>
    	<p>
    		<asp:GridView ID="GridViewSelect" runat="server" AllowPaging="True" 
    			AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlResultat">
    			<Columns>
    				<asp:CommandField ShowSelectButton="True" ButtonType="Image" 
    					SelectImageUrl="~/images/checkbox_vide.gif" />
    				<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" 
    					ReadOnly="True" SortExpression="id" />
    				<asp:BoundField DataField="reference" HeaderText="reference" 
    					SortExpression="reference" />
    				<asp:BoundField DataField="designation" HeaderText="designation" 
    					SortExpression="designation" />
    				<asp:BoundField DataField="categorie" HeaderText="categorie" 
    					SortExpression="categorie" />
    				<asp:BoundField DataField="type" HeaderText="type" SortExpression="type" />
    				<asp:BoundField DataField="service" HeaderText="service" 
    					SortExpression="service" />
    				<asp:BoundField DataField="remarques" HeaderText="remarques" 
    					SortExpression="remarques" />
    				<asp:BoundField DataField="annee" HeaderText="annee" SortExpression="annee" />
    				<asp:BoundField DataField="indice" HeaderText="indice" 
    					SortExpression="indice" />
    				<asp:BoundField DataField="datecreation" HeaderText="datecreation" 
    					SortExpression="datecreation" />
    				<asp:BoundField DataField="dateaplication" HeaderText="dateaplication" 
    					SortExpression="dateaplication" />
    				<asp:BoundField DataField="affichage" HeaderText="affichage" 
    					SortExpression="affichage" />
    				<asp:BoundField DataField="lien" HeaderText="lien" SortExpression="lien" />
    				<asp:CommandField ButtonType="Image" DeleteImageUrl="~/images/supprimer.jpg" 
    					DeleteText="" ShowDeleteButton="True" />
    			</Columns>
    		</asp:GridView>
    	</p>
    	<p>
    		&nbsp;<asp:SqlDataSource ID="SqlResultat" runat="server" 
    			ConnectionString="<%$ ConnectionStrings:GEDConnection %>" 
    			DeleteCommand="DELETE FROM [GED] WHERE [id] = @id" 
    			InsertCommand="INSERT INTO [GED] ([reference], [designation], [categorie], [type], [service], [remarques], [annee], [indice], [datecreation], [dateaplication], [affichage], [lien]) VALUES (@reference, @designation, @categorie, @type, @service, @remarques, @annee, @indice, @datecreation, @dateaplication, @affichage, @lien)" 
    			SelectCommand="SELECT * FROM [GED] WHERE (([categorie] = @categorie) AND ([type] = @type))" 
    			UpdateCommand="UPDATE [GED] SET [reference] = @reference, [designation] = @designation, [categorie] = @categorie, [type] = @type, [service] = @service, [remarques] = @remarques, [annee] = @annee, [indice] = @indice, [datecreation] = @datecreation, [dateaplication] = @dateaplication, [affichage] = @affichage, [lien] = @lien WHERE [id] = @id">
    			<DeleteParameters>
    				<asp:Parameter Name="id" Type="Int32" />
    			</DeleteParameters>
    			<InsertParameters>
    				<asp:Parameter Name="reference" Type="String" />
    				<asp:Parameter Name="designation" Type="String" />
    				<asp:Parameter Name="categorie" Type="String" />
    				<asp:Parameter Name="type" Type="String" />
    				<asp:Parameter Name="service" Type="String" />
    				<asp:Parameter Name="remarques" Type="String" />
    				<asp:Parameter Name="annee" Type="String" />
    				<asp:Parameter Name="indice" Type="String" />
    				<asp:Parameter Name="datecreation" Type="String" />
    				<asp:Parameter Name="dateaplication" Type="String" />
    				<asp:Parameter Name="affichage" Type="String" />
    				<asp:Parameter Name="lien" Type="String" />
    			</InsertParameters>
    			<SelectParameters>
    				<asp:ControlParameter ControlID="SelectCategorie" Name="categorie" 
    					PropertyName="SelectedValue" Type="String" />
    				<asp:ControlParameter ControlID="SelectType" Name="type" 
    					PropertyName="SelectedValue" Type="String" />
    			</SelectParameters>
    			<UpdateParameters>
    				<asp:Parameter Name="reference" Type="String" />
    				<asp:Parameter Name="designation" Type="String" />
    				<asp:Parameter Name="categorie" Type="String" />
    				<asp:Parameter Name="type" Type="String" />
    				<asp:Parameter Name="service" Type="String" />
    				<asp:Parameter Name="remarques" Type="String" />
    				<asp:Parameter Name="annee" Type="String" />
    				<asp:Parameter Name="indice" Type="String" />
    				<asp:Parameter Name="datecreation" Type="String" />
    				<asp:Parameter Name="dateaplication" Type="String" />
    				<asp:Parameter Name="affichage" Type="String" />
    				<asp:Parameter Name="lien" Type="String" />
    				<asp:Parameter Name="id" Type="Int32" />
    			</UpdateParameters>
    		</asp:SqlDataSource>
    		<asp:SqlDataSource ID="SqlCategorie" runat="server" 
    			ConnectionString="<%$ ConnectionStrings:BowdenGEDConnection %>" 
    			SelectCommand="SELECT DISTINCT [categorie] FROM [GED]"></asp:SqlDataSource>
    		<asp:SqlDataSource ID="SqlType" runat="server" 
    			ConnectionString="<%$ ConnectionStrings:BowdenGEDConnection %>" 
    			SelectCommand="SELECT DISTINCT [type] FROM [GED] WHERE ([categorie] = @categorie)">
    			<SelectParameters>
    				<asp:ControlParameter ControlID="SelectCategorie" Name="categorie" 
    					PropertyName="SelectedValue" Type="String" />
    			</SelectParameters>
    		</asp:SqlDataSource>
    	</p>
    	<p>
    		Vous pouvez également trouver de la <a href="http://go.microsoft.com/fwlink/?LinkID=152368"
    			title="Documentation ASP.NET sur MSDN">documentation sur ASP.NET sur MSDN</a>.
    	</p>
    </asp:Content>
    et le code VB
    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
    21
    22
    23
    24
    25
    26
    27
    28
    29
    Partial Class _Default
        Inherits System.Web.UI.Page
     
        Protected Sub GridViewSelect_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridViewSelect.SelectedIndexChanged
            Dim Lien As String
     
            HyperLink1.Text = GridViewSelect.SelectedRow.Cells(13).Text
            'HyperLink1.NavigateUrl = "file:///" + GridViewSelect.SelectedRow.Cells(13).Text
     
            Lien = HyperLink1.Text
            Lien = Replace(Lien, "é", "é")
     
            TextBox1.Text = Replace(Lien, "è", "è")
     
     
            TextBox1.Text = Replace(TextBox1.Text, "é", "é")
     
     
            HyperLink1.NavigateUrl = "file:///" + TextBox1.Text
     
            OpenFile(TextBox1.Text)
                End Sub
     
        Protected Sub modif_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles modif.Click
            Session("variable") = GridViewSelect.SelectedRow.Cells(1).Text
            Response.Redirect("Modification.aspx")
        End Sub
     
    End Class
    Merci a tous
    Brownie007

  2. #2
    Membre expérimenté
    Avatar de jbrasselet
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Mars 2006
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 022
    Points : 1 413
    Points
    1 413
    Par défaut
    A priori il faut que tu utilises la fonction urlEncode. Il devrait te transformer tout ça correctement

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 33
    Points : 24
    Points
    24
    Par défaut
    Merci de cette réponse rapide.
    as tu un exemple utilisant urlencode

    Brownie007

  4. #4
    Membre expérimenté
    Avatar de jbrasselet
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Mars 2006
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 022
    Points : 1 413
    Points
    1 413

  5. #5
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 33
    Points : 24
    Points
    24
    Par défaut
    Je viens d'utiliser urlencoder comme ceci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Dim Lien As String
     
            HyperLink1.Text = GridViewSelect.SelectedRow.Cells(13).Text
     
            Lien = HyperLink1.Text
            Lien = Replace(Lien, "é", "é")
            Lien = Replace(Lien, "è", "è")
            Lien = Replace(Lien, "é", "é")
     
            HyperLink1.NavigateUrl = "file:///" + Server.UrlEncode(Lien)
    Le souci est qu'il me remplace le é par é et le è par è

    Je sais plus comment faire

    Merci de votre aide

  6. #6
    Membre expérimenté
    Avatar de jbrasselet
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Mars 2006
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 022
    Points : 1 413
    Points
    1 413
    Par défaut
    UrlEncode te permet de transformer les chaines accentuées avec des espaces pour en faire des url valides.
    UrlDecode te permettra je pense de transformer tes valeurs é, etc. en valeurs lisibles.

    Que vaut ton Lien avant les replace ?

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 33
    Points : 24
    Points
    24
    Par défaut
    voici le resultat de différents test

    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
    21
      Dim Lien As String
     
            HyperLink1.Text = GridViewSelect.SelectedRow.Cells(13).Text
     
            Lien = HyperLink1.Text
            Response.Write(Lien)  'correct  cela affiche \\boyne03\_boynes\Qualite Boynes\Assurance Qualité\Environnement\Formulaires Environnement\test.xls
            TextBox1.Text = Lien  'correct
            Lien = Replace(Lien, "é", "é")
            Response.Write(Lien)  'correct
            TextBox2.Text = Lien  'correct
            Lien = Replace(Lien, "è", "è")
            Response.Write(Lien) 'correct
            TextBox3.Text = Lien  'correct
            Lien = Replace(Lien, "é", "é")
            Response.Write(Lien)  'correct
            TextBox4.Text = Lien  'correct
     
            Lien = "file:///" + Server.UrlEncode(HyperLink1.Text)
            Response.Write(Lien)  'INCORRECT
            TextBox5.Text = Lien 'Cela m'affiche file:///%5c%5cboyne03%5c_boynes%5cQualite+Boynes%5cAssurance+Qualit%26%23233%3b%5cEnvironnement%5cFormulaires+Environnement%5ctest.xls
            HyperLink1.NavigateUrl = Lien
    Merci à vous

  8. #8
    Membre expérimenté
    Avatar de jbrasselet
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Mars 2006
    Messages
    1 022
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 022
    Points : 1 413
    Points
    1 413
    Par défaut
    Je dois pas être réveillé mais si le lien est correct dès le début, quel est ton problème ?

  9. #9
    Membre à l'essai
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 33
    Points : 24
    Points
    24
    Par défaut
    c'est pour cela que ne comprend pas

    Le lien est bon dès le début , mias dès que je veux acceder au fichier via un hyperlink en utilisant "File:///" + Lien, cela transforme les accents.

    En fait je cherche simplement à ouvrir un fichier via un partage réseau

    Brownie007

Discussions similaires

  1. [Encodage] Problème d'encodage accents dans urls
    Par Jean-Georges dans le forum Langage
    Réponses: 2
    Dernier message: 13/09/2011, 11h47
  2. Htaccess convertir accents dans url
    Par ceweb dans le forum Apache
    Réponses: 4
    Dernier message: 25/11/2008, 20h41
  3. [HTML] Problème accent dans un password de FTP
    Par 22.icyo dans le forum Balisage (X)HTML et validation W3C
    Réponses: 6
    Dernier message: 07/01/2008, 18h52
  4. probléme accents dans rss xml
    Par gator dans le forum Langage
    Réponses: 6
    Dernier message: 25/07/2006, 13h36
  5. [PHP-JS] Problème accents dans script PHP
    Par zigor dans le forum Langage
    Réponses: 3
    Dernier message: 18/05/2006, 18h45

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo