Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Adapters / HtmlCommandAdapter.cs / 1305376 / HtmlCommandAdapter.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Drawing;
using System.Security.Permissions;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource
#else
namespace System.Web.UI.MobileControls.Adapters
#endif
{
/*
* HtmlCommandAdapter class.
*
* Copyright (c) 2000 Microsoft Corporation
*/
///
[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 HtmlCommandAdapter : HtmlControlAdapter
{
///
protected new Command Control
{
get
{
return (Command)base.Control;
}
}
///
public override void Render(HtmlMobileTextWriter writer)
{
bool renderLink = false;
bool renderImage = false;
// If image is defined and renderable, just do it. Otherwise,
// render as a link if specified.
if (!String.IsNullOrEmpty(Control.ImageUrl) &&
Device.SupportsImageSubmit)
{
renderImage = true;
}
else if (Control.Format == CommandFormat.Link &&
Device.JavaScript)
{
renderLink = true;
}
if (renderLink)
{
writer.EnterStyle(Style);
Form form = Control.Form;
if (form.Action.Length > 0)
{
writer.Write("");
writer.WriteText(Control.Text, true);
writer.WriteEndTag("a");
}
else
{
RenderBeginLink(writer, Constants.FormIDPrefix + form.UniqueID);
writer.WriteText(Control.Text, true);
RenderEndLink(writer);
}
writer.ExitStyle(Style, Control.BreakAfter);
}
else
{
writer.EnterLayout(Style);
writer.WriteBeginTag("input");
writer.WriteAttribute("name", Control.UniqueID);
if (renderImage)
{
writer.WriteAttribute("type", "image");
writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true);
writer.WriteAttribute("alt", Control.Text, true);
}
else
{
writer.WriteAttribute("type", "submit");
writer.Write(" value=\"");
writer.WriteText(Control.Text, true);
writer.Write("\"");
}
AddAttributes(writer);
writer.Write("/>");
writer.ExitLayout(Style, Control.BreakAfter);
}
}
///
public override bool LoadPostData(String key,
NameValueCollection data,
Object controlPrivateData,
out bool dataChanged)
{
dataChanged = false;
// HTML input tags of type image postback with the coordinates
// of the click rather than the name of the control.
String name = Control.UniqueID;
String postX = data[name + ".x"];
String postY = data[name + ".y"];
if (postX != null && postY != null
&& postX.Length > 0 && postY.Length > 0)
{
// set dataChannged to cause RaisePostDataChangedEvent()
dataChanged = true;
return true;
}
// For other command control, defer to default logic in control.
return false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Drawing;
using System.Security.Permissions;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource
#else
namespace System.Web.UI.MobileControls.Adapters
#endif
{
/*
* HtmlCommandAdapter class.
*
* Copyright (c) 2000 Microsoft Corporation
*/
///
[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 HtmlCommandAdapter : HtmlControlAdapter
{
///
protected new Command Control
{
get
{
return (Command)base.Control;
}
}
///
public override void Render(HtmlMobileTextWriter writer)
{
bool renderLink = false;
bool renderImage = false;
// If image is defined and renderable, just do it. Otherwise,
// render as a link if specified.
if (!String.IsNullOrEmpty(Control.ImageUrl) &&
Device.SupportsImageSubmit)
{
renderImage = true;
}
else if (Control.Format == CommandFormat.Link &&
Device.JavaScript)
{
renderLink = true;
}
if (renderLink)
{
writer.EnterStyle(Style);
Form form = Control.Form;
if (form.Action.Length > 0)
{
writer.Write("");
writer.WriteText(Control.Text, true);
writer.WriteEndTag("a");
}
else
{
RenderBeginLink(writer, Constants.FormIDPrefix + form.UniqueID);
writer.WriteText(Control.Text, true);
RenderEndLink(writer);
}
writer.ExitStyle(Style, Control.BreakAfter);
}
else
{
writer.EnterLayout(Style);
writer.WriteBeginTag("input");
writer.WriteAttribute("name", Control.UniqueID);
if (renderImage)
{
writer.WriteAttribute("type", "image");
writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true);
writer.WriteAttribute("alt", Control.Text, true);
}
else
{
writer.WriteAttribute("type", "submit");
writer.Write(" value=\"");
writer.WriteText(Control.Text, true);
writer.Write("\"");
}
AddAttributes(writer);
writer.Write("/>");
writer.ExitLayout(Style, Control.BreakAfter);
}
}
///
public override bool LoadPostData(String key,
NameValueCollection data,
Object controlPrivateData,
out bool dataChanged)
{
dataChanged = false;
// HTML input tags of type image postback with the coordinates
// of the click rather than the name of the control.
String name = Control.UniqueID;
String postX = data[name + ".x"];
String postY = data[name + ".y"];
if (postX != null && postY != null
&& postX.Length > 0 && postY.Length > 0)
{
// set dataChannged to cause RaisePostDataChangedEvent()
dataChanged = true;
return true;
}
// For other command control, defer to default logic in control.
return false;
}
}
}
// 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
- ElementAction.cs
- DisableDpiAwarenessAttribute.cs
- NativeMethods.cs
- CharEntityEncoderFallback.cs
- ConfigurationValidatorAttribute.cs
- MachineKeyConverter.cs
- MappedMetaModel.cs
- Token.cs
- SystemParameters.cs
- InheritanceContextHelper.cs
- MetabaseServerConfig.cs
- Win32SafeHandles.cs
- SingleTagSectionHandler.cs
- SafePointer.cs
- DateTimePicker.cs
- Zone.cs
- MenuTracker.cs
- SystemKeyConverter.cs
- PolicyStatement.cs
- VectorValueSerializer.cs
- XsltOutput.cs
- ChannelDispatcherBase.cs
- XmlSchemaSequence.cs
- CaseInsensitiveComparer.cs
- NonVisualControlAttribute.cs
- Block.cs
- RegexRunner.cs
- MailWriter.cs
- mediaeventshelper.cs
- BitmapSource.cs
- Camera.cs
- SqlMetaData.cs
- ValidationPropertyAttribute.cs
- DrawingContextWalker.cs
- ColumnWidthChangedEvent.cs
- UIPropertyMetadata.cs
- XmlCollation.cs
- AssociationType.cs
- BindingCollection.cs
- EndOfStreamException.cs
- FlowDocumentPaginator.cs
- TextEndOfParagraph.cs
- GridPatternIdentifiers.cs
- DataGridViewCellParsingEventArgs.cs
- BaseParagraph.cs
- ReferencedCollectionType.cs
- FilteredAttributeCollection.cs
- Error.cs
- Function.cs
- _KerberosClient.cs
- GlyphRunDrawing.cs
- XmlParser.cs
- DateTimeFormat.cs
- Assert.cs
- MetabaseServerConfig.cs
- CoreSwitches.cs
- LocatorBase.cs
- IntPtr.cs
- ProfileSection.cs
- EdmRelationshipRoleAttribute.cs
- HttpPostedFile.cs
- Trace.cs
- LoginView.cs
- RuntimeVariablesExpression.cs
- ToolStripPanelRow.cs
- TrackingRecordPreFilter.cs
- SqlGatherConsumedAliases.cs
- remotingproxy.cs
- DateTimeOffset.cs
- ToolboxItem.cs
- ProcessStartInfo.cs
- TypeSystem.cs
- GridItemProviderWrapper.cs
- BulletChrome.cs
- CompositeCollection.cs
- XmlCharacterData.cs
- SchemaComplexType.cs
- ValidationError.cs
- ConstraintManager.cs
- EventHandlersStore.cs
- UidPropertyAttribute.cs
- UserControlCodeDomTreeGenerator.cs
- AssemblyResourceLoader.cs
- CodeNamespaceImport.cs
- SyndicationContent.cs
- Point3D.cs
- AssemblyInfo.cs
- StylusPointProperty.cs
- SimpleMailWebEventProvider.cs
- PingOptions.cs
- ManifestSignatureInformation.cs
- EventSinkActivity.cs
- HttpRequest.cs
- JoinSymbol.cs
- QueryPageSettingsEventArgs.cs
- HttpModuleCollection.cs
- SafeProcessHandle.cs
- ExecutionContext.cs
- sapiproxy.cs
- PageStatePersister.cs