bonjour, j'ai fait un webcontrol :
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
using System;
using System.ComponentModel;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace Classes.WebControls
{
    /// <summary>
    /// Desciription de wbcFlash
    /// WebControl servant à l'intégration d'élément Flash
    /// </summary>
    [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal),
    AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal),
    DefaultProperty("swfurl"),
  ToolboxData("<{0}:wbcFlash runat=\"server\"> </{0}:wbcFlash>")]
    public class wbcFlash : WebControl
    {
 
        #region Attributs du webcontrol
 
        [Bindable(true),
        Category("Appearance"),
        DefaultValue(""),
        Description("Chemin du FLASH"),
        Localizable(true)]
        public virtual string swfurl
        {
            get
            {
                string s = (string)ViewState["swfurl"];
                return (s == null) ? String.Empty : s;
            }
            set
            {
                ViewState["swfurl"] = value;
            }
        }
 
 
 
        [Bindable(true),
        Category("Appearance"),
        DefaultValue(""),
        Description("Url des scripts nécessaires à Flash"),
        Localizable(true)]
        public virtual string swfobjectid
        {
            get
            {
                string s = (string)ViewState["swfobjectid"];
                return (s == null) ? String.Empty : s;
            }
            set
            {
                ViewState["swfobjectid"] = value;
            }
        }
 
        [Bindable(true),
        Category("Appearance"),
        DefaultValue(400),
        Description("Hauteur du flash"),
        Localizable(true)]
        public virtual int swfheight
        {
            get
            {
                int s = 400;
                if (ViewState["swfheight"] != null)
                {
                    s = int.Parse(ViewState["swfheight"].ToString());
                }
                return s;
            }
            set
            {
                ViewState["swfheight"] = value.ToString();
            }
        }
 
        [Bindable(true),
        Category("Appearance"),
        DefaultValue(500),
        Description("Largeur du flash"),
        Localizable(true)]
        public virtual int swfwidth
        {
            get
            {
                int s = 500;
                if (ViewState["swfwidth"] != null)
                {
                    s = int.Parse(ViewState["swfwidth"].ToString());
                }
                return s;
            }
            set
            {
                ViewState["Width"] = value.ToString();
            }
        }
 
        [Bindable(true),
Category("Appearance"),
DefaultValue(9),
Description("Version du player flash"),
Localizable(true)]
        public virtual int flashplayerversion
        {
            get
            {
                int s = 500;
                if (ViewState["flashplayerversion"] != null)
                {
                    s = int.Parse(ViewState["flashplayerversion"].ToString());
                }
                return s;
            }
            set
            {
                ViewState["flashplayerversion"] = value.ToString();
            }
        }
 
        [Bindable(true),
Category("Appearance"),
DefaultValue("#FFFFFF"),
Description("Couleur de fond de l'animation flash Flash"),
Localizable(true)]
        public virtual string swfbackcolor
        {
            get
            {
                string s = (string)ViewState["swfbackcolor"];
                return (s == null) ? String.Empty : s;
            }
            set
            {
                ViewState["swfbackcolor"] = value;
            }
        }
 
        #endregion
 
        protected override void RenderContents(HtmlTextWriter writer)
        {
            // on ajoute le chargement du fichier swfobject
            //Page.ClientScript.RegisterStartupScript(this.GetType(), "Flash", "<script language=\"JavaScript\" src=\"" + "/_Ressources/ExercicePlayer/swfobject.js\"></script> ");
 
            string v_flash = this.swfurl + "?random=" + System.Guid.NewGuid().ToString();
 
            string jscript = "";
            jscript += "\r\n<script language=\"JavaScript\" type=\"text/javascript\">\r\n";
            jscript += "var so = new SWFObject(\"" + v_flash + "\", \"" + this.swfobjectid + "\", \"" + this.swfwidth + "\", \"" + this.swfheight + "\", \"" + this.flashplayerversion + "\", \"" + this.swfbackcolor + "\");\r\n";
            jscript += "so.write(\"flashcontent\");\r\n";
            jscript += "\r\n</script>";
 
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Flash_Movie", jscript);
        }
 
 
        public wbcFlash()
        {
        }
    }
}
Mais quand je l'insere dans la page, le code généré est le :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
<table>
<tr>
<td>
<span id="ctl00_ContentPlaceHolder1_swfrrr"></span>
</td></tr>
</table>
et puis plus loin
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
<script language="JavaScript" type="text/javascript">
var so = new SWFObject("/_Ressources/ExercicePlayer/index.swf?random=cc03d358-99d3-4b87-b798-a2585744074f", "index", "500", "613", "9", "#FFFFFF");
so.write("flashcontent");
</script>
Je ne comprends pas pourquoi le code fait par mon RenderContents n'est pas dans mon <span id="ctl00_ContentPlaceHolder1_swfrrr"> ???