using System using System Data using System Configuration using System

 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
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
namespace AJAX_CustomControl
{
public class MediaPlayerButton : Image, IScriptControl
{
private string _playImageUrl;
private string _pauseImageUrl;
private ScriptManager _scriptManager;
public string PlayImageUrl
{
get { return _playImageUrl; }
set { this._playImageUrl = value; }
}
public string PauseImageUrl
{
get { return _pauseImageUrl; }
set { this._pauseImageUrl = value; }
}
protected override void OnPreRender(EventArgs e)
{
if (!this.DesignMode)
{
_scriptManager = ScriptManager.GetCurrent(Page);
if (_scriptManager == null)
{
throw new HttpException("A ScriptManager control must exist on the current page");
}
_scriptManager.RegisterScriptControl(this);
}
base.OnPreRender(e);
}
protected override void Render(HtmlTextWriter writer)
{
if (!this.DesignMode)
{
_scriptManager.RegisterScriptDescriptors(this);
}
base.Render(writer);
}
#region IScriptControl Members
public IEnumerable<ScriptDescriptor> GetScriptDescriptors()
{
ScriptBehaviorDescriptor descriptor = new ScriptBehaviorDescriptor("CustomControls", "MediaPlayerControl1");
descriptor.AddProperty("playImageUrl", this.PlayImageUrl);
descriptor.AddProperty("pauseImageUrl", this.PauseImageUrl);
return new ScriptDescriptor[] { descriptor };
}
public IEnumerable<ScriptReference> GetScriptReferences()
{
ScriptReference reference = new ScriptReference();
reference.Path = ResolveClientUrl("MediaPlayerButton.js");
ScriptReferenceCollection _reference = new ScriptReferenceCollection();
_reference.Add(reference);
return _reference;
}
#endregion
}
}