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 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
//------------------------------------------------------------------------------
// <copyright file="TextBox.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.Design.WebControls;
using System.Web.UI.HtmlControls;
using System.Security.Permissions;
namespace System.Web.UI.MobileControls
{
/*
* Mobile TextBox class.
*
* Copyright (c) 2000 Microsoft Corporation
*/
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox"]/*' />
[
ControlBuilderAttribute(typeof(TextBoxControlBuilder)),
DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + AssemblyRef.SystemDesign),
DefaultEvent("TextChanged"),
DefaultProperty("Text"),
Designer(typeof(System.Web.UI.Design.MobileControls.TextBoxDesigner)),
DesignerAdapter(typeof(System.Web.UI.Design.MobileControls.Adapters.DesignerTextBoxAdapter)),
ToolboxData("<{0}:TextBox runat=\"server\"></{0}:TextBox>"),
ToolboxItem("System.Web.UI.Design.WebControlToolboxItem, " + AssemblyRef.SystemDesign),
ValidationProperty("Text")
]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
public class TextBox : TextControl, IPostBackDataHandler
{
private static readonly Object EventTextChanged = new Object();
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.IPostBackDataHandler.LoadPostData"]/*' />
/// <internalonly/>
protected bool LoadPostData(String key, NameValueCollection data)
{
bool dataChanged = false;
bool handledByAdapter =
Adapter.LoadPostData(key, data, null, out dataChanged);
if (!handledByAdapter)
{
String value = data[key];
if (Text != value)
{
Text = value;
dataChanged = true; // this will cause a RaisePostDataChangedEvent()
}
}
return dataChanged;
}
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.IPostBackDataHandler.RaisePostDataChangedEvent"]/*' />
/// <internalonly/>
protected void RaisePostDataChangedEvent()
{
OnTextChanged(EventArgs.Empty);
}
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.OnTextChanged"]/*' />
protected virtual void OnTextChanged(EventArgs e)
{
EventHandler onTextChangedHandler = (EventHandler)Events[EventTextChanged];
if (onTextChangedHandler != null)
{
onTextChangedHandler(this,e);
}
}
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.Password"]/*' />
[
Bindable(true),
Browsable(true),
DefaultValue(false),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.TextBox_Password)
]
public bool Password
{
get
{
Object b = ViewState["Password"];
return (b != null) ? (bool)b : false;
}
set
{
ViewState["Password"] = value;
}
}
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.Numeric"]/*' />
[
Bindable(true),
Browsable(true),
DefaultValue(false),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.TextBox_Numeric)
]
public bool Numeric
{
get
{
Object b = ViewState["Numeric"];
return (b != null) ? (bool)b : false;
}
set
{
ViewState["Numeric"] = value;
}
}
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.Size"]/*' />
[
Bindable(true),
DefaultValue(0),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.TextBox_Size)
]
public int Size
{
get
{
Object i = ViewState["Size"];
return((i != null) ? (int)i : 0);
}
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException("Size", value,
SR.GetString(SR.TextBox_NotNegativeNumber));
}
ViewState["Size"] = value;
}
}
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.MaxLength"]/*' />
[
Bindable(true),
DefaultValue(0),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.TextBox_MaxLength)
]
public int MaxLength
{
get
{
Object i = ViewState["MaxLength"];
return((i != null) ? (int)i : 0);
}
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException("MaxLength", value,
SR.GetString(SR.TextBox_NotNegativeNumber));
}
ViewState["MaxLength"] = value;
}
}
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.TextChanged"]/*' />
[
MobileSysDescription(SR.TextBox_OnTextChanged)
]
public event EventHandler TextChanged
{
add
{
Events.AddHandler(EventTextChanged, value);
}
remove
{
Events.RemoveHandler(EventTextChanged, value);
}
}
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.Title"]/*' />
[
Bindable(true),
DefaultValue(""),
MobileCategory(SR.Category_Appearance),
MobileSysDescription(SR.Input_Title)
]
public String Title
{
get
{
return ToString(ViewState["Title"]);
}
set
{
ViewState["Title"] = value;
}
}
internal override bool TrimInnerText
{
get
{
return false;
}
}
internal override bool TrimNewlines
{
get
{
return true;
}
}
#region IPostBackDataHandler implementation
bool IPostBackDataHandler.LoadPostData(String key, NameValueCollection data) {
return LoadPostData(key, data);
}
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
#endregion
}
/*
* TextBox Control Builder
*
* Copyright (c) 2000 Microsoft Corporation
*/
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBoxControlBuilder"]/*' />
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
public class TextBoxControlBuilder : MobileControlBuilder
{
// Textbox allows whitespace inside text.
/// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBoxControlBuilder.AllowWhitespaceLiterals"]/*' />
public override bool AllowWhitespaceLiterals()
{
return true;
}
}
}
|