Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Project
- |...Controls
- |...MyDateTimePicker.cs
- |...MyDateTimePicker.js
- [assembly: System.Web.UI.WebResource("Project.Controls.MyDateTimePicker.js", "text/javascript")]
- [DefaultProperty("ID")]
- [ToolboxData("<{0}:MyDateTimePicker runat=server />")]
- public class MyDateTimePicker : WebControl, IScriptControl
- {
- }
- protected override void OnPreRender(EventArgs e)
- {
- if (!this.DesignMode)
- {
- // Link the script up with the script manager
- ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
- if (scriptManager != null)
- {
- scriptManager.RegisterScriptControl(this);
- scriptManager.RegisterScriptDescriptors(this);
- scriptManager.Scripts.Add(new ScriptReference(
- "Project.Controls.MyDateTimePicker.js", "Project"));
- }
- else
- {
- throw new ApplicationException("You must have a ScriptManager on the Page.");
- }
- }
- base.OnPreRender(e);
- }
- public virtual string TimeHourFormat {get;set;}
- public virtual string TimeFormat {get;set;}
- IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors()
- {
- ScriptControlDescriptor desc = new ScriptControlDescriptor("Project.MyDateTimePicker",
- this.ClientID);
- // Properties
- desc.AddProperty("timeHourFormat", this.TimeHourFormat);
- desc.AddProperty("timeFormat", this.TimeFormat);
- yield return desc;
- }
- IEnumerable<ScriptReference> IScriptControl.GetScriptReferences()
- {
- ScriptReference reference = new ScriptReference();
- reference.Assembly = Assembly.GetAssembly(typeof(MyDateTimePicker)).FullName;
- reference.Name = "Project.MyDateTimePicker.js";
- yield return reference;
- }
- Type.registerNamespace('Project');
- Project.MyDateTimePicker = function (element) {
- this._timeHourFormat = null;
- this._timeFormat = null;
- // Calling the base class constructor
- Project.MyDateTimePicker.initializeBase(this, [element]);
- }
- Project.MyDateTimePicker.prototype =
- {
- initialize: function () {
- // Call the base initialize method
- Project.MyDateTimePicker.callBaseMethod(this, 'initialize');
- $(document).ready(
- // See, jQuery!
- );
- },
- dispose: function () {
- // Call the base class method
- Project.MyDateTimePicker.callBaseMethod(this, 'dispose');
- },
- //////////////////
- // Public Methods
- //////////////////
- // Hides the control from view
- doSomething: function (e) {
- },
- //////////////////
- // Properties
- //////////////////
- get_timeHourFormat: function () {
- return this._timeHourFormat;
- },
- set_timeHourFormat: function (value) {
- var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);
- if (e) throw e;
- if (this._timeHourFormat != value) {
- this._timeHourFormat = value;
- this.raisePropertyChanged('timeHourFormat');
- }
- },
- get_timeFormat: function () {
- return this._timeFormat;
- },
- set_timeFormat: function (value) {
- var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);
- if (e) throw e;
- if (this._timeFormat != value) {
- this._timeFormat = value;
- this.raisePropertyChanged('timeFormat');
- }
- }
- }
- Project.MyDateTimePicker.registerClass('Project.MyDateTimePicker', Sys.UI.Control);
- if (typeof(Sys) != 'undefined')
- {
- Sys.Application.notifyScriptLoaded();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement