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

C# Discussion :

Appeler des fonctions C# dans du code html [Débutant]


Sujet :

C#

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 488
    Points : 134
    Points
    134
    Par défaut Appeler des fonctions C# dans du code html
    Bonjour,

    Voilà je travaille sur un programme qui me permet de modifier le fond d'une page html.
    J'ai pour celà deux procédures C#: L'une me permettant d'attribuer un fond d'écran et l'autre me retourne le chemin de l'image à charger.

    Pour choisir le fond d'écran, je passe par un lien html, comment appeler ma procédure C#? Doit-elle être définie dans la page html en question?
    Même question pour récupérer le chemin de l'image à afficher:

    Voici les 3 endroits concernés par la modification:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <table width="900" border="0" cellpadding="0" cellspacing="0" background="../images/fond1.jpg" class="pageBorder">
     
    <div id="content" style="background-image: url(../images/fond1.jpg);" >
     
    <td height="25" background="../images/fond1.jpg">
    Que dois-je mettre à la place de Dois-je passer par des fontions javascript?
    Si oui, pourrais-je appeler ma fonction C#?

    Merci d'avance pour votre réponse.

  2. #2
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 488
    Points : 134
    Points
    134
    Par défaut
    Je met le code ma page aspx, ce sera peut être un peut plus parlant/
    Je n'arrive pas a appeler la fonction chooseBackgroung() (C#) à partir de ma fonction setBackGroud() (JS)

    Merci d'avance pour votre aide.

    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
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    <% @Page Language="C#" Debug="true" %>
    <% @Import Namespace="System" %>
    <% @Import Namespace="System.Xml" %>
    <% @Import Namespace="System.IO" %>
    <% @Import Namespace="System.Xml.XPath" %>
    <script runat="server">
    	protected String chooseBG()
    	{
    		return "Hello";
    	}
     
    	protected void chooseBackGround(string[] r)
        {
    	try
            {
                //String[] r = { "agence3", "sheira", "fondK.jpg" };
     
     
                String filename = "test.xml";
     
                using (FileStream f = new FileStream(HttpContext.Current.Server.MapPath(filename), FileMode.OpenOrCreate, FileAccess.ReadWrite))
                {
                    if (f.Length != 0)
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.Load(f);
                        XmlElement racine = doc.DocumentElement;
                        //  on vérifie d'abord que la balise groupe existe 
                        if (racine != null && racine.Name == "groupe")
                        {
                            XmlNodeList noeudsAgence = racine.ChildNodes;
                            if (noeudsAgence.Count > 0)
                            {
                                // on vérifie que le noeud n'existe pas avant de le créer
                                bool agenceExist = false;
                                bool utilisateurExist = false;
                                foreach (XmlNode noeudAgence in noeudsAgence)
                                {
                                    if (noeudAgence.Attributes["nom"].InnerText == r[0])
                                    {
                                        agenceExist = true;
                                        foreach (XmlNode utilisateur in noeudAgence.ChildNodes)
                                        {
    										Response.Write (utilisateur.InnerText); 
                                            if (utilisateur.InnerText == r[1])
                                            {
                                                utilisateurExist = true;
                                                utilisateur.Attributes["fond"].Value = r[2];
                                                break;
                                            }
                                        }
                                        if (!utilisateurExist)
                                        {
                                            XmlElement user = doc.CreateElement("utilisateur");
                                            user.InnerText = r[1];
                                            XmlAttribute attrFond = doc.CreateAttribute("fond");
                                            attrFond.Value = r[2];
                                            user.SetAttributeNode(attrFond);
                                            noeudAgence.AppendChild(user);
                                        }
                                    }
     
                                }
     
                                if (!agenceExist)
                                {
                                    XmlElement ag = doc.CreateElement("agence");
                                    XmlAttribute attrNom = doc.CreateAttribute("nom");
                                    attrNom.Value = r[0];
                                    ag.SetAttributeNode(attrNom);
                                    XmlElement user = doc.CreateElement("utilisateur");
                                    user.InnerText = r[1];
                                    XmlAttribute attrFond = doc.CreateAttribute("fond");
                                    attrFond.Value = r[2];
                                    user.SetAttributeNode(attrFond);
                                    ag.AppendChild(user);
                                    racine.AppendChild(ag);
                                }
                                f.Close();
                                doc.Save(HttpContext.Current.Server.MapPath(filename));
     
                            }
                        }
     
                    }
                    else
                    {
                        XmlDocument doc = new XmlDocument();
                        XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "Utf-8", null);
                        doc.AppendChild(declaration);
                        XmlElement racine = doc.CreateElement("groupe");
                        XmlElement ag = doc.CreateElement("agence");
                        XmlAttribute attrNom = doc.CreateAttribute("nom");
                        attrNom.Value = r[0];
                        ag.SetAttributeNode(attrNom);
                        XmlElement user = doc.CreateElement("utilisateur");
                        user.InnerText = r[1];
                        XmlAttribute attrFond = doc.CreateAttribute("fond");
                        attrFond.Value = r[2];
                        user.SetAttributeNode(attrFond);
                        ag.AppendChild(user);
                        racine.AppendChild(ag);
                        doc.AppendChild(racine);
                        doc.Save(f);
                    }
     
     
                }
            }
            catch (Exception ex)
            {
                //Todo:gestion des exceptions
            }
     
     
    	}
     
    </script>
    <HTML>
    <HEAD>
    <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
    <script language= "Javascript" type= "text/javascript" >
     
    function getVar (nomVariable)
    {
    	var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)+"&"
    	if (infos.indexOf("#")!=-1)
    		infos = infos.substring(0,infos.indexOf("#"))+"&"
    		var variable=0
    		{
    		nomVariable = nomVariable + "="
    		var taille = nomVariable.length
    		if (infos.indexOf(nomVariable)!=-1)
    		variable = infos.substring(infos.indexOf(nomVariable)+taille,infos.length).substring(0,infos.substring(infos.indexOf(nomVariable)+taille,infos.length).indexOf("&"))
    		}
    	return variable
    } 
     
    function setBackGround(strFond)
    {
    	var groupe = getVar('groupe');
    	var nom = getVar('nom');
    	var data = [];
    	data.push(groupe, nom);
    	data.push(strFond);
    	//alert (data.join(","));
     
    	alert("<%= chooseBG() %>;
     
    	<% 
    	String[] r = { "agence4", "Olivier", "fondO.jpg" };
    	/*String agence = Request.Params["groupe"];*/
    	String prenom = Request.Params["nom"];
     
    	//chooseBackGround(r);
    	%>
     
     
    }
     
     
    </script>
     
    <script language= "C#" type= "text/C#" runat= "Server">
    	private void chooseBackgroud()
    	{
    	}
     
    </script>
     
    </HEAD>
    <BODY>
    	<table width=50  height =50>
    		<tr width=50 align="center">
                		<font size="10%" color="#D5CCCD">Définir un nouveau fond d'écran</font>
                    </tr>
    		<tr width=25>
    			<td  width=5  height =5><a href = "javascript:setBackGround('fond1.jpg');" title = "Choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>1.1
    			<td  width=5  height =5><a href = "" title = "Choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    			<td  width=5  height =5><a href = "" title = "Choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    			<td  width=5  height =5><a href = "" title = "Choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    		</tr>
     
    		<tr></tr>
    		<tr></tr>
    		<tr width=25>
    			<td  width=5  height =5><a href = "" title = "Choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    			<td  width=5  height =5><a href = "" title = "Choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    			<td  width=5  height =5><a href = "" title = "Choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    			<td  width=5  height =5><a href = "" title = "Choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    		</tr>
     
    	</table>
     
    </BODY>
    </HTML>

  3. #3
    Expert confirmé

    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2010
    Messages
    2 066
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Novembre 2010
    Messages : 2 066
    Points : 4 233
    Points
    4 233
    Par défaut
    je vais être sympa je vais encore t'aider tu peux rajouter la balise runat="server" a ta balise html pour pouvoir directement l'appeler dans ton code c# avec son id exemple:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <div id="content" style="background-image: url(../images/fond1.jpg);"  runat="server" >
    et dans ton code c# tu peux modifier le style
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    content.Style.Add(HtmlTextWriterStyle.BackgroundImage,"url(../images/fond1.jpg)");

  4. #4
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 488
    Points : 134
    Points
    134
    Par défaut
    Merci youtpout978!!

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    content.Style.Add(HtmlTextWriterStyle.BackgroundImage,"url(../images/fond1.jpg)");
    Ca veut dire que j'aurai pu mettre ce que je veux dans le second argumenet de la fonction "Add"?
    Exemple:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    content.Style.Add(HtmlTextWriterStyle.BackgroundImage,"url(../images/fond23.jpg)");
    pour me changer mon fond1 en fond23??

  5. #5
    Expert confirmé

    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2010
    Messages
    2 066
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Novembre 2010
    Messages : 2 066
    Points : 4 233
    Points
    4 233
    Par défaut
    c'est une string tu peux donc la construire dynamiquement si tu veux (à partir de la valeur fond de ton fichier xml par exemple)

  6. #6
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 488
    Points : 134
    Points
    134
    Par défaut
    ok super pour la changement du fond ça marche nikel!
    Merci!

    Maintenant j'aimerai pouvoir alimenter mon fichier xml depuis une autre page xml et là ça coince.
    J'ai essayé de suivre à peu près le même principe mais ça ne fonctionne pas.
    Voici mon code:
    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
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
     
    <% @Page Language="C#" Debug="true" %>
    <% @Import Namespace="System" %>
    <% @Import Namespace="System.Web" %>
    <% @Import Namespace="System.Xml" %>
    <% @Import Namespace="System.IO" %>
    <% @Import Namespace="System.Xml.XPath" %>
    <script runat="server">
    	public String chooseBG()
    	{
    		return "Hello";
    	}
     
    	protected void ahrefChooseBackGround_Click(String fond)
        {
    	try
            {
                //String[] r = { "agence3", "sheira", "fondK.jpg" };
    			String agence = HttpContext.Current.Request.Params["groupe"];
    			String prenom = HttpContext.Current.Request.Params["nom"];
    			String[] r = new String []{ agence, prenom, fond};
     
                String filename = "test.xml";
                using (FileStream f = new FileStream(HttpContext.Current.Server.MapPath(filename), FileMode.OpenOrCreate, FileAccess.ReadWrite))
                {
                    if (f.Length != 0)
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.Load(f);
                        XmlElement racine = doc.DocumentElement;
                        //  on vérifie d'abord que la balise groupe existe 
                        if (racine != null && racine.Name == "groupe")
                        {
                            XmlNodeList noeudsAgence = racine.ChildNodes;
                            if (noeudsAgence.Count > 0)
                            {
                                // on vérifie que le noeud n'existe pas avant de le créer
    							bool agenceExist = false;
                                bool utilisateurExist = false;
                                foreach (XmlNode noeudAgence in noeudsAgence)
                                {
                                    if (noeudAgence.Attributes["nom"].InnerText == r[0])
                                    {
                                        agenceExist = true;
                                        foreach (XmlNode utilisateur in noeudAgence.ChildNodes)
                                        {
    										Response.Write (utilisateur.InnerText); 
                                            if (utilisateur.InnerText == r[1])
                                            {
                                                utilisateurExist = true;
                                                utilisateur.Attributes["fond"].Value = r[2];
                                                break;
                                            }
                                        }
                                        if (!utilisateurExist)
                                        {
                                            XmlElement user = doc.CreateElement("utilisateur");
                                            user.InnerText = r[1];
                                            XmlAttribute attrFond = doc.CreateAttribute("fond");
                                            attrFond.Value = r[2];
                                            user.SetAttributeNode(attrFond);
                                            noeudAgence.AppendChild(user);
                                        }
                                    }
     
                                }
     
                                if (!agenceExist)
                                {
                                    XmlElement ag = doc.CreateElement("agence");
                                    XmlAttribute attrNom = doc.CreateAttribute("nom");
                                    attrNom.Value = r[0];
                                    ag.SetAttributeNode(attrNom);
                                    XmlElement user = doc.CreateElement("utilisateur");
                                    user.InnerText = r[1];
                                    XmlAttribute attrFond = doc.CreateAttribute("fond");
                                    attrFond.Value = r[2];
                                    user.SetAttributeNode(attrFond);
                                    ag.AppendChild(user);
                                    racine.AppendChild(ag);
                                }
                                f.Close();
                                doc.Save(HttpContext.Current.Server.MapPath(filename));
                             }
                        }
                    }
                    else
                    {
                        XmlDocument doc = new XmlDocument();
                        XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "Utf-8", null);
                        doc.AppendChild(declaration);
                        XmlElement racine = doc.CreateElement("groupe");
                        XmlElement ag = doc.CreateElement("agence");
                        XmlAttribute attrNom = doc.CreateAttribute("nom");
                        attrNom.Value = r[0];
                        ag.SetAttributeNode(attrNom);
                        XmlElement user = doc.CreateElement("utilisateur");
                        user.InnerText = r[1];
                        XmlAttribute attrFond = doc.CreateAttribute("fond");
                        attrFond.Value = r[2];
                        user.SetAttributeNode(attrFond);
                        ag.AppendChild(user);
                        racine.AppendChild(ag);
                        doc.AppendChild(racine);
                        doc.Save(f);
                    }
                }
            }
            catch (Exception ex)
            {
                //Todo:gestion des exceptions
            }
    	}
     
    </script>
    <HTML>
    <HEAD>
    <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
    <script language= "Javascript" type= "text/javascript" >
     
    function getVar (nomVariable)
    {
    	var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)+"&"
    	if (infos.indexOf("#")!=-1)
    		infos = infos.substring(0,infos.indexOf("#"))+"&"
    		var variable=0
    		{
    		nomVariable = nomVariable + "="
    		var taille = nomVariable.length
    		if (infos.indexOf(nomVariable)!=-1)
    		variable = infos.substring(infos.indexOf(nomVariable)+taille,infos.length).substring(0,infos.substring(infos.indexOf(nomVariable)+taille,infos.length).indexOf("&"))
    		}
    	return variable
    } 
     
    function setBackGround(strFond)
    {
    	var groupe = getVar('groupe');
    	var nom = getVar('nom');
    	var data = [];
    	data.push(groupe, nom);
    	data.push(strFond);
    	//alert (data.join(","));
     
    	//alert("<%= chooseBG() %>;
     
    	<% 
    	String[] r = { "agence4", "Olivier", "fondO.jpg" };
    	/*String agence = HttpContext.Current.Request.Params["groupe"];*/
    	String prenom = HttpContext.Current.Request.Params["nom"];
    	Response.Write(prenom);
    	//chooseBackGround(r);
    	%>
    }
    </script>
    </HEAD>
    <BODY>
    	<form runat="server">
    		<table width=50  height =50>
    			<tr width=50 align="center">
                	<font size="10%" color="#D5CCCD">Définir un nouveau fond d'écran</font>
                </tr>
    			<tr width=25>
    				<td  width=5  height =5><a href = "default.aspx" id="ahrefChooseBackGround" runat = "server" onclick="ahrefChooseBackGround_Click("fond1.jpg")" title = "Cliquer pour choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    				<td  width=5  height =5><a href = "" id="ahrefChooseBackGround2" runat = "server" onclick="ahrefChooseBackGround_Click("fond1.jpg")" title = "Cliquer pour choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    				<td  width=5  height =5><a href = "" id="ahrefChooseBackGround3" runat = "server" onclick="ahrefChooseBackGround_Click("fond1.jpg")" title = "Cliquer pour choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    				<td  width=5  height =5><a href = "" id="ahrefChooseBackGround4" runat = "server" onclick="ahrefChooseBackGround_Click("fond1.jpg")" title = "Cliquer pour choisir ce fond"><img src="../images/fond1.jpg" width=180 height=180></a></td>
    			</tr>
    			<tr></tr>
    			<tr></tr>
    			<tr width=25>
    				<td  width=5  height =5><a href = "" id="ahrefChooseBackGround5" runat = "server" onclick="ahrefChooseBackGround_Click("fond2.jpg")" title = "Cliquer pour choisir ce fond"><img src="../images/fond2.jpg" width=180 height=180></a></td>
    				<td  width=5  height =5><a href = "" id="ahrefChooseBackGround6" runat = "server" onclick="ahrefChooseBackGround_Click("fond2.jpg")" title = "Cliquer pour choisir ce fond"><img src="../images/fond2.jpg" width=180 height=180></a></td>
    				<td  width=5  height =5><a href = "" id="ahrefChooseBackGround7" runat = "server" onclick="ahrefChooseBackGround_Click("fond2.jpg")" title = "Cliquer pour choisir ce fond"><img src="../images/fond2.jpg" width=180 height=180></a></td>
    				<td  width=5  height =5><a href = "" id="ahrefChooseBackGround8" runat = "server" onclick="ahrefChooseBackGround_Click("fond2.jpg")" title = "Cliquer pour choisir ce fond"><img src="../images/fond2.jpg" width=180 height=180></a></td>
    			</tr>
    		</table>
    	</form>
    </BODY>
    </HTML>
    Merci d'avance

  7. #7
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 488
    Points : 134
    Points
    134
    Par défaut
    J'ai un peu avancé:

    en faisant ça, ça fonctionne

    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
     
    <tr width=25>
    				<td  width=5  height =5>
    					<asp:LinkButton ID="ahrefChooseBackGround" Title = "Choisir ce fond" onclick="ahrefChooseBackGround_Click" runat = "server">
    						<asp:Image ID="image1" ImageUrl= "../images/fond1.jpg" width=180 height=180 runat="server" />
    					</asp:LinkButton>
    				</td>
    				<td  width=5  height =5>
    					<asp:LinkButton ID="ahrefChooseBackGround1" Title = "Choisir ce fond" onclick="ahrefChooseBackGround_Click" runat = "server">
    						<asp:Image ID="image2" ImageUrl= "../images/fond1.jpg" width=180 height=180 runat="server" />
    					</asp:LinkButton>
    				</td>
    				<td  width=5  height =5>
    					<asp:LinkButton ID="ahrefChooseBackGround2" Title = "Choisir ce fond" onclick="ahrefChooseBackGround_Click" runat = "server">
    						<asp:Image ID="image3" ImageUrl= "../images/fond1.jpg" width=180 height=180 runat="server" />
    					</asp:LinkButton>
    				</td>
    				<td  width=5  height =5>
    					<asp:LinkButton ID="ahrefChooseBackGround3" Title = "Choisir ce fond" onclick="ahrefChooseBackGround_Click" runat = "server">
    						<asp:Image ID="image4" ImageUrl= "../images/fond1.jpg" width=180 height=180 runat="server" />
    					</asp:LinkButton>
    				</td>
    			</tr>

    Par contre est-ce qu'il y a un moyen que je récupère la valeur de


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ImageUrl= "../images/fond1.jpg"
    dans ma fonction ahrefChooseBackGround_Click, j'en ai besoin pour connaître le nom de l'image ??

    Merci pour votre aide.

  8. #8
    Expert confirmé

    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2010
    Messages
    2 066
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Novembre 2010
    Messages : 2 066
    Points : 4 233
    Points
    4 233
    Par défaut
    c'est une balise asp tu as donc accès à tous ces attributs depuis le code tu as juste à faire ça par exemple:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    string cheminImage=image4.ImageUrl;

  9. #9
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 488
    Points : 134
    Points
    134
    Par défaut
    Merci Youtpout978!!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [.net]Appeler une fonction située dans le code behind
    Par anto dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 20/05/2009, 13h05
  2. Appeler des fonctions listées dans un tableau
    Par MarieNum dans le forum ActionScript 3
    Réponses: 2
    Dernier message: 01/01/2009, 17h31
  3. appeler une fonction javascript dans le code html
    Par kawther dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 16/05/2007, 16h40
  4. Réponses: 2
    Dernier message: 19/09/2006, 19h06
  5. Appel à des fonctions incluses dans des DLL
    Par Greybird dans le forum Langage
    Réponses: 3
    Dernier message: 26/05/2003, 13h33

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