|
|
@@ -8,6 +8,8 @@
|
|
|
* Status: 60%
|
|
|
*
|
|
|
* (C) Gaurav Vaish (2001)
|
|
|
+ * Thanks to Leen Toelen ([email protected])'s classes that helped me
|
|
|
+ * to write the contents of the function LoadPostData(...)
|
|
|
*/
|
|
|
|
|
|
using System;
|
|
|
@@ -111,23 +113,102 @@ namespace System.Web.UI.WebControls
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected virtual void OnPreRender(EventArgs e)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
protected override void Render(HtmlTextWriter writer)
|
|
|
{
|
|
|
//TODO: THE LOST WORLD!
|
|
|
- // I know I have to do it.
|
|
|
+ bool hasBeginRendering = false;
|
|
|
+ if(ControlStyleCreated)
|
|
|
+ {
|
|
|
+ if(!ControlStyle.IsEmpty)
|
|
|
+ {
|
|
|
+ hasBeginRendering = true;
|
|
|
+ ControlStyle.AddAttributesToRender(writer, this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Enabled)
|
|
|
+ {
|
|
|
+ hasBeginRendering = true;
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.Disbled, "disabled");
|
|
|
+ }
|
|
|
+ if(ToolTip.Length > 0)
|
|
|
+ {
|
|
|
+ hasBeginRendering = true;
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.Title, ToolTip);
|
|
|
+ }
|
|
|
+ if(Attributes.Count > 0)
|
|
|
+ {
|
|
|
+ hasBeginRendering = true;
|
|
|
+ Attributes.AddAttributes(writer);
|
|
|
+ }
|
|
|
+ if(hasBeginRendering)
|
|
|
+ writer.RenderBeginTag(HtmlTextWriterTag.Span);
|
|
|
+ if(Text.Length > 0)
|
|
|
+ {
|
|
|
+ // Looks wierd, ain't? But found out interestingly.
|
|
|
+ if(TextAlign == TextAlign.Right)
|
|
|
+ {
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.For, ClientID);
|
|
|
+ writer.RenderBeginTag(HtmlTextWriterTag.Label);
|
|
|
+ writer.Write(Text);
|
|
|
+ writer.RenderEngTag();
|
|
|
+ RenderInputTag(writer, ClientID);
|
|
|
+ } else
|
|
|
+ {
|
|
|
+ RenderInputTag(writer, ClientID);
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.For, ClientID);
|
|
|
+ writer.RenderBeginTag(HtmlTextWriterTag.Label);
|
|
|
+ writer.Write(Text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(hasBeginRendering)
|
|
|
+ writer.RenderEndTag();
|
|
|
+ }
|
|
|
+
|
|
|
+ internal virtual void RenderInputTag(HtmlTextWriter writer, string clientId)
|
|
|
+ {
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.Id, clientId);
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox");
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
|
|
|
+ if(Checked)
|
|
|
+ {
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked");
|
|
|
+ }
|
|
|
+ if(AutoPostBack)
|
|
|
+ {
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.OnClick,Page.GetPostBackClientEvent(this, String.Empty));
|
|
|
+ writer.AddAttribute("language", "javascript");
|
|
|
+ }
|
|
|
+ if(AccessKey.Length > 0)
|
|
|
+ {
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.AccessKey, AccessKey);
|
|
|
+ }
|
|
|
+ if(TabIndex != 0)
|
|
|
+ {
|
|
|
+ writer.AddAttribute(HtmlTextWriterAttribute.TabIndex, TabIndex.ToString(NumberFormatInfo.InvariantInfo));
|
|
|
+ }
|
|
|
+ writer.RenderBeginTag(HtmlTextWriterTag.Input);
|
|
|
+ writer.RenderEndTag();
|
|
|
}
|
|
|
|
|
|
public bool LoadPostData(string postDataKey, NameValueCollection postCollection)
|
|
|
{
|
|
|
- //TODO: THE LOST WORLD
|
|
|
- // Now what the hell is this!
|
|
|
- return false;
|
|
|
+ string postedVal = postCollection[postDataKey];
|
|
|
+ bool postChecked = false;
|
|
|
+ if(postedVal != null)
|
|
|
+ {
|
|
|
+ postChecked = postedVal.Length > 0;
|
|
|
+ }
|
|
|
+ Checked = postChecked;
|
|
|
+ return (postChecked == Checked == false);
|
|
|
}
|
|
|
|
|
|
public void RaisePostDataChangedEvent()
|
|
|
{
|
|
|
- //TODO: THE LOST WORLD...
|
|
|
- // Raise the bucket out of the well :))
|
|
|
OnCheckedChanged(EventArgs.Empty);
|
|
|
}
|
|
|
}
|