Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Command.cs / 1305376 / Command.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Drawing.Design;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;
namespace System.Web.UI.MobileControls
{
/*
* Mobile Command class.
*
* Copyright (c) 2000 Microsoft Corporation
*/
///
[
DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + AssemblyRef.SystemDesign),
DefaultEvent("Click"),
DefaultProperty("Text"),
Designer(typeof(System.Web.UI.Design.MobileControls.CommandDesigner)),
DesignerAdapter(typeof(System.Web.UI.Design.MobileControls.Adapters.DesignerCommandAdapter)),
ToolboxData("<{0}:Command runat=\"server\">Command{0}:Command>"),
ToolboxItem("System.Web.UI.Design.WebControlToolboxItem, " + AssemblyRef.SystemDesign)
]
[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 Command : TextControl, IPostBackEventHandler, IPostBackDataHandler
{
private static readonly Object EventClick = new Object ();
private static readonly Object EventItemCommand = new Object ();
///
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
// If this control will be rendered as an image
Debug.Assert(ImageUrl != null);
if (MobilePage != null
&& ImageUrl.Length != 0
&& MobilePage.Device.SupportsImageSubmit)
{
// HTML input controls of type image postback as name.x and
// name.y which is not associated with this control by default
// in Page.ProcessPostData().
MobilePage.RegisterRequiresPostBack(this);
}
}
///
protected bool LoadPostData(String key, NameValueCollection data)
{
bool dataChanged;
bool handledByAdapter =
Adapter.LoadPostData(key, data, null, out dataChanged);
// If the adapter handled the post back and set dataChanged this
// was an image button (responds with ID.x and ID.y).
if (handledByAdapter)
{
if(dataChanged)
{
Page.RegisterRequiresRaiseEvent(this);
}
}
// Otherwise if the adapter did not handle the past back, use
// the same method as Page.ProcessPostData().
else if(data[key] != null)
{
Page.RegisterRequiresRaiseEvent(this);
}
return false; // no need to raise PostDataChangedEvent.
}
///
protected void RaisePostDataChangedEvent() {
}
///
[
Bindable(true),
DefaultValue(""),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.Command_SoftkeyLabel)
]
public String SoftkeyLabel
{
get
{
String s = (String) ViewState["Softkeylabel"];
return((s != null) ? s : String.Empty);
}
set
{
ViewState["Softkeylabel"] = value;
}
}
///
[
Bindable(true),
DefaultValue(""),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.Command_CommandName)
]
public String CommandName
{
get
{
String s = (String) ViewState["CommandName"];
return((s != null) ? s : String.Empty);
}
set
{
ViewState["CommandName"] = value;
}
}
///
[
Bindable(true),
DefaultValue(""),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.Command_CommandArgument)
]
public String CommandArgument
{
get
{
String s = (String) ViewState["CommandArgument"];
return((s != null) ? s : String.Empty);
}
set
{
ViewState["CommandArgument"] = value;
}
}
///
[
Bindable(true),
DefaultValue(""),
Editor(typeof(System.Web.UI.Design.MobileControls.ImageUrlEditor),
typeof(UITypeEditor)),
MobileCategory(SR.Category_Appearance),
MobileSysDescription(SR.Image_ImageUrl)
]
public String ImageUrl
{
get
{
String s = (String) ViewState["ImageUrl"];
return((s != null) ? s : String.Empty);
}
set
{
ViewState["ImageUrl"] = value;
}
}
///
[
Bindable(false),
DefaultValue(true),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.Command_CausesValidation)
]
public bool CausesValidation
{
get
{
object b = ViewState["CausesValidation"];
return((b == null) ? true : (bool)b);
}
set
{
ViewState["CausesValidation"] = value;
}
}
///
[
Bindable(true),
DefaultValue(CommandFormat.Button),
MobileCategory(SR.Category_Appearance),
MobileSysDescription(SR.Command_Format)
]
public CommandFormat Format
{
get
{
Object o = ViewState["Format"];
return((o == null) ? CommandFormat.Button : (CommandFormat)o);
}
set
{
ViewState["Format"] = value;
}
}
///
protected virtual void OnClick(EventArgs e)
{
EventHandler onClickHandler = (EventHandler)Events[EventClick];
if (onClickHandler != null)
{
onClickHandler(this,e);
}
}
///
protected virtual void OnItemCommand(CommandEventArgs e)
{
CommandEventHandler onItemCommandHandler = (CommandEventHandler)Events[EventItemCommand];
if (onItemCommandHandler != null)
{
onItemCommandHandler(this,e);
}
RaiseBubbleEvent (this, e);
}
///
[
MobileCategory(SR.Category_Action),
MobileSysDescription(SR.Command_OnClick)
]
public event EventHandler Click
{
add
{
Events.AddHandler(EventClick, value);
}
remove
{
Events.RemoveHandler(EventClick, value);
}
}
///
[
MobileCategory(SR.Category_Action),
MobileSysDescription(SR.Command_OnItemCommand)
]
public event CommandEventHandler ItemCommand
{
add
{
Events.AddHandler(EventItemCommand, value);
}
remove
{
Events.RemoveHandler(EventItemCommand, value);
}
}
///
///
protected void RaisePostBackEvent(String argument)
{
if (CausesValidation)
{
MobilePage.Validate();
}
// It is legitimate to reset the form back to the first page
// after a form submit.
Form.CurrentPage = 1;
OnClick (EventArgs.Empty);
OnItemCommand (new CommandEventArgs(CommandName, CommandArgument));
}
///
protected override bool IsFormSubmitControl()
{
return true;
}
#region IPostBackEventHandler implementation
void IPostBackEventHandler.RaisePostBackEvent(String eventArgument) {
RaisePostBackEvent(eventArgument);
}
#endregion
#region IPostBackDataHandler implementation
bool IPostBackDataHandler.LoadPostData(String key, NameValueCollection data) {
return LoadPostData(key, data);
}
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Drawing.Design;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;
namespace System.Web.UI.MobileControls
{
/*
* Mobile Command class.
*
* Copyright (c) 2000 Microsoft Corporation
*/
///
[
DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + AssemblyRef.SystemDesign),
DefaultEvent("Click"),
DefaultProperty("Text"),
Designer(typeof(System.Web.UI.Design.MobileControls.CommandDesigner)),
DesignerAdapter(typeof(System.Web.UI.Design.MobileControls.Adapters.DesignerCommandAdapter)),
ToolboxData("<{0}:Command runat=\"server\">Command{0}:Command>"),
ToolboxItem("System.Web.UI.Design.WebControlToolboxItem, " + AssemblyRef.SystemDesign)
]
[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 Command : TextControl, IPostBackEventHandler, IPostBackDataHandler
{
private static readonly Object EventClick = new Object ();
private static readonly Object EventItemCommand = new Object ();
///
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
// If this control will be rendered as an image
Debug.Assert(ImageUrl != null);
if (MobilePage != null
&& ImageUrl.Length != 0
&& MobilePage.Device.SupportsImageSubmit)
{
// HTML input controls of type image postback as name.x and
// name.y which is not associated with this control by default
// in Page.ProcessPostData().
MobilePage.RegisterRequiresPostBack(this);
}
}
///
protected bool LoadPostData(String key, NameValueCollection data)
{
bool dataChanged;
bool handledByAdapter =
Adapter.LoadPostData(key, data, null, out dataChanged);
// If the adapter handled the post back and set dataChanged this
// was an image button (responds with ID.x and ID.y).
if (handledByAdapter)
{
if(dataChanged)
{
Page.RegisterRequiresRaiseEvent(this);
}
}
// Otherwise if the adapter did not handle the past back, use
// the same method as Page.ProcessPostData().
else if(data[key] != null)
{
Page.RegisterRequiresRaiseEvent(this);
}
return false; // no need to raise PostDataChangedEvent.
}
///
protected void RaisePostDataChangedEvent() {
}
///
[
Bindable(true),
DefaultValue(""),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.Command_SoftkeyLabel)
]
public String SoftkeyLabel
{
get
{
String s = (String) ViewState["Softkeylabel"];
return((s != null) ? s : String.Empty);
}
set
{
ViewState["Softkeylabel"] = value;
}
}
///
[
Bindable(true),
DefaultValue(""),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.Command_CommandName)
]
public String CommandName
{
get
{
String s = (String) ViewState["CommandName"];
return((s != null) ? s : String.Empty);
}
set
{
ViewState["CommandName"] = value;
}
}
///
[
Bindable(true),
DefaultValue(""),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.Command_CommandArgument)
]
public String CommandArgument
{
get
{
String s = (String) ViewState["CommandArgument"];
return((s != null) ? s : String.Empty);
}
set
{
ViewState["CommandArgument"] = value;
}
}
///
[
Bindable(true),
DefaultValue(""),
Editor(typeof(System.Web.UI.Design.MobileControls.ImageUrlEditor),
typeof(UITypeEditor)),
MobileCategory(SR.Category_Appearance),
MobileSysDescription(SR.Image_ImageUrl)
]
public String ImageUrl
{
get
{
String s = (String) ViewState["ImageUrl"];
return((s != null) ? s : String.Empty);
}
set
{
ViewState["ImageUrl"] = value;
}
}
///
[
Bindable(false),
DefaultValue(true),
MobileCategory(SR.Category_Behavior),
MobileSysDescription(SR.Command_CausesValidation)
]
public bool CausesValidation
{
get
{
object b = ViewState["CausesValidation"];
return((b == null) ? true : (bool)b);
}
set
{
ViewState["CausesValidation"] = value;
}
}
///
[
Bindable(true),
DefaultValue(CommandFormat.Button),
MobileCategory(SR.Category_Appearance),
MobileSysDescription(SR.Command_Format)
]
public CommandFormat Format
{
get
{
Object o = ViewState["Format"];
return((o == null) ? CommandFormat.Button : (CommandFormat)o);
}
set
{
ViewState["Format"] = value;
}
}
///
protected virtual void OnClick(EventArgs e)
{
EventHandler onClickHandler = (EventHandler)Events[EventClick];
if (onClickHandler != null)
{
onClickHandler(this,e);
}
}
///
protected virtual void OnItemCommand(CommandEventArgs e)
{
CommandEventHandler onItemCommandHandler = (CommandEventHandler)Events[EventItemCommand];
if (onItemCommandHandler != null)
{
onItemCommandHandler(this,e);
}
RaiseBubbleEvent (this, e);
}
///
[
MobileCategory(SR.Category_Action),
MobileSysDescription(SR.Command_OnClick)
]
public event EventHandler Click
{
add
{
Events.AddHandler(EventClick, value);
}
remove
{
Events.RemoveHandler(EventClick, value);
}
}
///
[
MobileCategory(SR.Category_Action),
MobileSysDescription(SR.Command_OnItemCommand)
]
public event CommandEventHandler ItemCommand
{
add
{
Events.AddHandler(EventItemCommand, value);
}
remove
{
Events.RemoveHandler(EventItemCommand, value);
}
}
///
///
protected void RaisePostBackEvent(String argument)
{
if (CausesValidation)
{
MobilePage.Validate();
}
// It is legitimate to reset the form back to the first page
// after a form submit.
Form.CurrentPage = 1;
OnClick (EventArgs.Empty);
OnItemCommand (new CommandEventArgs(CommandName, CommandArgument));
}
///
protected override bool IsFormSubmitControl()
{
return true;
}
#region IPostBackEventHandler implementation
void IPostBackEventHandler.RaisePostBackEvent(String eventArgument) {
RaisePostBackEvent(eventArgument);
}
#endregion
#region IPostBackDataHandler implementation
bool IPostBackDataHandler.LoadPostData(String key, NameValueCollection data) {
return LoadPostData(key, data);
}
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StickyNoteHelper.cs
- AnnotationObservableCollection.cs
- OleDbFactory.cs
- XmlCountingReader.cs
- SelectionRange.cs
- HttpRuntimeSection.cs
- DescendantOverDescendantQuery.cs
- ThreadAbortException.cs
- StoreAnnotationsMap.cs
- NamespaceDecl.cs
- SecurityHelper.cs
- WeakEventManager.cs
- WebPartEventArgs.cs
- ClockController.cs
- UdpMessageProperty.cs
- RelationshipManager.cs
- NativeObjectSecurity.cs
- CustomCredentialPolicy.cs
- DataGridViewColumnConverter.cs
- FixedSOMPageElement.cs
- DebuggerAttributes.cs
- SiteMapHierarchicalDataSourceView.cs
- SqlInternalConnectionSmi.cs
- Empty.cs
- ProtocolViolationException.cs
- HelpInfo.cs
- PageContent.cs
- GridViewColumnCollection.cs
- ClrProviderManifest.cs
- BooleanAnimationBase.cs
- SizeAnimationClockResource.cs
- MouseButton.cs
- dataprotectionpermission.cs
- BindingContext.cs
- PreservationFileReader.cs
- FrameworkElementFactory.cs
- ProgressBarRenderer.cs
- HttpResponseBase.cs
- DbParameterHelper.cs
- ClientRolePrincipal.cs
- Pen.cs
- RectangleHotSpot.cs
- OdbcInfoMessageEvent.cs
- BypassElementCollection.cs
- EntityClientCacheKey.cs
- DocumentOrderQuery.cs
- DataListItemEventArgs.cs
- AssertFilter.cs
- CodeTypeDeclarationCollection.cs
- Attachment.cs
- XmlAutoDetectWriter.cs
- ToolStripTextBox.cs
- CodeSubDirectory.cs
- DataViewListener.cs
- IDQuery.cs
- NameValueSectionHandler.cs
- DataGridViewCellMouseEventArgs.cs
- DbProviderManifest.cs
- Number.cs
- LogicalTreeHelper.cs
- GenericAuthenticationEventArgs.cs
- PackagePartCollection.cs
- DataGridViewRowPostPaintEventArgs.cs
- BatchStream.cs
- PixelFormatConverter.cs
- XmlName.cs
- CodeValidator.cs
- SBCSCodePageEncoding.cs
- TextRunProperties.cs
- ComPersistableTypeElement.cs
- ModelServiceImpl.cs
- Logging.cs
- NamespaceQuery.cs
- RangeValidator.cs
- Vector3dCollection.cs
- FileStream.cs
- PartManifestEntry.cs
- ConsumerConnectionPoint.cs
- ResXBuildProvider.cs
- SchemaCollectionCompiler.cs
- RbTree.cs
- EventRecordWrittenEventArgs.cs
- HtmlShimManager.cs
- CellCreator.cs
- PackagePartCollection.cs
- TraceProvider.cs
- PackageFilter.cs
- HwndHost.cs
- SystemIPGlobalStatistics.cs
- SingletonConnectionReader.cs
- NativeWindow.cs
- ObjectContext.cs
- SmiContext.cs
- DbConnectionPoolCounters.cs
- BuildManagerHost.cs
- ScrollContentPresenter.cs
- IndexingContentUnit.cs
- WebPartVerbsEventArgs.cs
- TemplateBamlTreeBuilder.cs
- HostingEnvironmentSection.cs