Advertisement
Guest User

Untitled

a guest
Sep 21st, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. Project
  2. |...Controls
  3. |...MyDateTimePicker.cs
  4. |...MyDateTimePicker.js
  5.  
  6. [assembly: System.Web.UI.WebResource("Project.Controls.MyDateTimePicker.js", "text/javascript")]
  7.  
  8. [DefaultProperty("ID")]
  9. [ToolboxData("<{0}:MyDateTimePicker runat=server />")]
  10. public class MyDateTimePicker : WebControl, IScriptControl
  11. {
  12.  
  13. }
  14.  
  15. protected override void OnPreRender(EventArgs e)
  16. {
  17.  
  18. if (!this.DesignMode)
  19. {
  20.  
  21. // Link the script up with the script manager
  22. ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
  23. if (scriptManager != null)
  24. {
  25. scriptManager.RegisterScriptControl(this);
  26. scriptManager.RegisterScriptDescriptors(this);
  27. scriptManager.Scripts.Add(new ScriptReference(
  28. "Project.Controls.MyDateTimePicker.js", "Project"));
  29. }
  30. else
  31. {
  32. throw new ApplicationException("You must have a ScriptManager on the Page.");
  33. }
  34.  
  35. }
  36.  
  37. base.OnPreRender(e);
  38.  
  39. }
  40.  
  41. public virtual string TimeHourFormat {get;set;}
  42. public virtual string TimeFormat {get;set;}
  43.  
  44. IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors()
  45. {
  46. ScriptControlDescriptor desc = new ScriptControlDescriptor("Project.MyDateTimePicker",
  47. this.ClientID);
  48.  
  49. // Properties
  50. desc.AddProperty("timeHourFormat", this.TimeHourFormat);
  51. desc.AddProperty("timeFormat", this.TimeFormat);
  52.  
  53. yield return desc;
  54. }
  55.  
  56. IEnumerable<ScriptReference> IScriptControl.GetScriptReferences()
  57. {
  58. ScriptReference reference = new ScriptReference();
  59. reference.Assembly = Assembly.GetAssembly(typeof(MyDateTimePicker)).FullName;
  60. reference.Name = "Project.MyDateTimePicker.js";
  61. yield return reference;
  62. }
  63.  
  64. Type.registerNamespace('Project');
  65.  
  66. Project.MyDateTimePicker = function (element) {
  67.  
  68. this._timeHourFormat = null;
  69. this._timeFormat = null;
  70.  
  71. // Calling the base class constructor
  72. Project.MyDateTimePicker.initializeBase(this, [element]);
  73.  
  74. }
  75.  
  76. Project.MyDateTimePicker.prototype =
  77. {
  78.  
  79. initialize: function () {
  80.  
  81. // Call the base initialize method
  82. Project.MyDateTimePicker.callBaseMethod(this, 'initialize');
  83.  
  84. $(document).ready(
  85. // See, jQuery!
  86. );
  87.  
  88. },
  89.  
  90. dispose: function () {
  91.  
  92. // Call the base class method
  93. Project.MyDateTimePicker.callBaseMethod(this, 'dispose');
  94.  
  95. },
  96.  
  97.  
  98. //////////////////
  99. // Public Methods
  100. //////////////////
  101.  
  102. // Hides the control from view
  103. doSomething: function (e) {
  104.  
  105. },
  106.  
  107. //////////////////
  108. // Properties
  109. //////////////////
  110.  
  111. get_timeHourFormat: function () {
  112. return this._timeHourFormat;
  113. },
  114. set_timeHourFormat: function (value) {
  115. var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);
  116. if (e) throw e;
  117. if (this._timeHourFormat != value) {
  118. this._timeHourFormat = value;
  119. this.raisePropertyChanged('timeHourFormat');
  120. }
  121. },
  122.  
  123. get_timeFormat: function () {
  124. return this._timeFormat;
  125. },
  126. set_timeFormat: function (value) {
  127. var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);
  128. if (e) throw e;
  129. if (this._timeFormat != value) {
  130. this._timeFormat = value;
  131. this.raisePropertyChanged('timeFormat');
  132. }
  133. }
  134.  
  135. }
  136.  
  137.  
  138. Project.MyDateTimePicker.registerClass('Project.MyDateTimePicker', Sys.UI.Control);
  139.  
  140. if (typeof(Sys) != 'undefined')
  141. {
  142. Sys.Application.notifyScriptLoaded();
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement