Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Adapters / ChtmlFormAdapter.cs / 1305376 / ChtmlFormAdapter.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System.Globalization;
using System.Security.Permissions;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource
#else
namespace System.Web.UI.MobileControls.Adapters
#endif
{
/*
* ChtmlFormAdapter 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 ChtmlFormAdapter : HtmlFormAdapter
{
private static readonly String _contentTypeMetaTag = "\r\n";
///
protected override bool ShouldRenderFormTag()
{
if (!Device.RequiresOutputOptimization || Control.PageCount > 1)
{
return true;
}
return IsFormTagNeeded(Control);
}
// Recursive method to check if there is any descendant control
// requires the form tag. For unknown cases, the method returns true
// in case the unknown rendering requires the form tag.
private bool IsFormTagNeeded(Control control)
{
// Check itself first
if (!control.Visible)
{
return false;
}
MobileControl mobileControl = control as MobileControl;
if (mobileControl != null)
{
// Since we don't have control over what content is included
// in the template, to be safe we just generate the form tag.
if (mobileControl.IsTemplated)
{
return true;
}
HtmlControlAdapter adapter = mobileControl.Adapter as HtmlControlAdapter;
if (adapter != null && adapter.RequiresFormTag)
{
return true;
}
}
else if (!(control is UserControl) &&
!(control is LiteralControl))
{
// UserControl simply acts as a container, so the checking
// should be delegated to its children below.
// LiteralControl is a plain text control. Also, it is
// generated for the spaces in between mobile control tags so
// we don't want to consider it as a form required control.
// For other cases, we should generate form tag as we don't
// know the content that will be generated.
return true;
}
// No problem with the current control so far, now recursively
// check its children.
if (control.HasControls())
{
foreach (Control child in control.Controls)
{
if (IsFormTagNeeded(child))
{
// This is to get out of recursive loop without
// further checking on other controls.
return true;
}
}
}
return false;
}
///
protected override bool RenderExtraHeadElements(HtmlMobileTextWriter writer)
{
bool result = false;
String metaTagName = Device.RequiredMetaTagNameValue;
if (metaTagName != null)
{
if (writer != null)
{
writer.Write("\r\n");
}
result = true;
}
String charset = Page.Response.Charset;
if (Device.RequiresContentTypeMetaTag &&
charset != null && charset.Length > 0)
{
if (writer != null)
{
writer.Write(String.Format(CultureInfo.InvariantCulture, _contentTypeMetaTag, Device.PreferredRenderingMime, charset));
}
result = true;
}
return result;
}
///
protected internal override void RenderPagerTag(
HtmlMobileTextWriter writer,
int pageToNavigate,
String text)
{
writer.EnterLayout(Style);
writer.EnterFormat(Style);
writer.WriteBeginTag("input");
// Specially encode the page number with the control id.
// The corresponding code that handles postback should know how
// to extract the page number correctly.
writer.Write(" name=\"");
writer.Write(Control.UniqueID);
writer.Write(Constants.PagePrefix);
writer.Write(pageToNavigate.ToString(CultureInfo.InvariantCulture));
writer.Write("\"");
writer.WriteAttribute("type", "submit");
writer.WriteAttribute("value", text, true);
writer.Write("/>");
writer.ExitFormat(Style);
writer.ExitLayout(Style);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System.Globalization;
using System.Security.Permissions;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource
#else
namespace System.Web.UI.MobileControls.Adapters
#endif
{
/*
* ChtmlFormAdapter 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 ChtmlFormAdapter : HtmlFormAdapter
{
private static readonly String _contentTypeMetaTag = "\r\n";
///
protected override bool ShouldRenderFormTag()
{
if (!Device.RequiresOutputOptimization || Control.PageCount > 1)
{
return true;
}
return IsFormTagNeeded(Control);
}
// Recursive method to check if there is any descendant control
// requires the form tag. For unknown cases, the method returns true
// in case the unknown rendering requires the form tag.
private bool IsFormTagNeeded(Control control)
{
// Check itself first
if (!control.Visible)
{
return false;
}
MobileControl mobileControl = control as MobileControl;
if (mobileControl != null)
{
// Since we don't have control over what content is included
// in the template, to be safe we just generate the form tag.
if (mobileControl.IsTemplated)
{
return true;
}
HtmlControlAdapter adapter = mobileControl.Adapter as HtmlControlAdapter;
if (adapter != null && adapter.RequiresFormTag)
{
return true;
}
}
else if (!(control is UserControl) &&
!(control is LiteralControl))
{
// UserControl simply acts as a container, so the checking
// should be delegated to its children below.
// LiteralControl is a plain text control. Also, it is
// generated for the spaces in between mobile control tags so
// we don't want to consider it as a form required control.
// For other cases, we should generate form tag as we don't
// know the content that will be generated.
return true;
}
// No problem with the current control so far, now recursively
// check its children.
if (control.HasControls())
{
foreach (Control child in control.Controls)
{
if (IsFormTagNeeded(child))
{
// This is to get out of recursive loop without
// further checking on other controls.
return true;
}
}
}
return false;
}
///
protected override bool RenderExtraHeadElements(HtmlMobileTextWriter writer)
{
bool result = false;
String metaTagName = Device.RequiredMetaTagNameValue;
if (metaTagName != null)
{
if (writer != null)
{
writer.Write("\r\n");
}
result = true;
}
String charset = Page.Response.Charset;
if (Device.RequiresContentTypeMetaTag &&
charset != null && charset.Length > 0)
{
if (writer != null)
{
writer.Write(String.Format(CultureInfo.InvariantCulture, _contentTypeMetaTag, Device.PreferredRenderingMime, charset));
}
result = true;
}
return result;
}
///
protected internal override void RenderPagerTag(
HtmlMobileTextWriter writer,
int pageToNavigate,
String text)
{
writer.EnterLayout(Style);
writer.EnterFormat(Style);
writer.WriteBeginTag("input");
// Specially encode the page number with the control id.
// The corresponding code that handles postback should know how
// to extract the page number correctly.
writer.Write(" name=\"");
writer.Write(Control.UniqueID);
writer.Write(Constants.PagePrefix);
writer.Write(pageToNavigate.ToString(CultureInfo.InvariantCulture));
writer.Write("\"");
writer.WriteAttribute("type", "submit");
writer.WriteAttribute("value", text, true);
writer.Write("/>");
writer.ExitFormat(Style);
writer.ExitLayout(Style);
}
}
}
// 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
- CategoryAttribute.cs
- ValueUnavailableException.cs
- ObjectIDGenerator.cs
- srgsitem.cs
- ItemCheckedEvent.cs
- StateWorkerRequest.cs
- XmlSchemaSimpleContent.cs
- Properties.cs
- ContextMenu.cs
- XmlAttributes.cs
- ParameterExpression.cs
- FixedStringLookup.cs
- ProcessHostFactoryHelper.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- StateRuntime.cs
- StreamGeometryContext.cs
- Activity.cs
- TableChangeProcessor.cs
- CfgArc.cs
- LabelAutomationPeer.cs
- WriteTimeStream.cs
- EntityDescriptor.cs
- TableChangeProcessor.cs
- RewritingValidator.cs
- BufferModesCollection.cs
- SiteIdentityPermission.cs
- XamlFrame.cs
- FormsAuthenticationModule.cs
- BulletedListEventArgs.cs
- SetState.cs
- ObjectListShowCommandsEventArgs.cs
- ToolStripCustomTypeDescriptor.cs
- _ListenerRequestStream.cs
- addressfiltermode.cs
- WorkflowDurableInstance.cs
- ObjectViewListener.cs
- InteropTrackingRecord.cs
- IndependentAnimationStorage.cs
- DataBindingCollection.cs
- ValueUnavailableException.cs
- PriorityQueue.cs
- FileSystemWatcher.cs
- _ConnectStream.cs
- BlockCollection.cs
- DetailsViewPagerRow.cs
- Point4DConverter.cs
- WindowsListViewGroup.cs
- ErrorWrapper.cs
- BindingSource.cs
- CompressStream.cs
- EdmPropertyAttribute.cs
- CodeTypeDelegate.cs
- DashStyle.cs
- MethodBody.cs
- ResourceExpressionBuilder.cs
- DateTimeConstantAttribute.cs
- SurrogateChar.cs
- CultureInfo.cs
- ScriptingAuthenticationServiceSection.cs
- PermissionSet.cs
- FtpWebRequest.cs
- WebConfigurationHost.cs
- PairComparer.cs
- CommandLibraryHelper.cs
- ProfileModule.cs
- SizeAnimationUsingKeyFrames.cs
- CompilationSection.cs
- ToolStripDropDownButton.cs
- MexNamedPipeBindingCollectionElement.cs
- PersonalizationEntry.cs
- LayoutUtils.cs
- securitycriticaldata.cs
- ChangeDirector.cs
- ConnectionStringsSection.cs
- CodeThrowExceptionStatement.cs
- ActiveXContainer.cs
- CollectionView.cs
- TagMapCollection.cs
- BufferedMessageWriter.cs
- ExpressionEditorAttribute.cs
- SafeFileMappingHandle.cs
- sqlmetadatafactory.cs
- FormViewInsertEventArgs.cs
- EntityDataSourceQueryBuilder.cs
- ComponentChangedEvent.cs
- DbConnectionPoolOptions.cs
- IdentityManager.cs
- ButtonBaseAutomationPeer.cs
- PeerCustomResolverSettings.cs
- NameNode.cs
- ApplicationActivator.cs
- LinkGrep.cs
- UnsafeCollabNativeMethods.cs
- ColorInterpolationModeValidation.cs
- XNodeNavigator.cs
- FixedPageProcessor.cs
- StringAnimationUsingKeyFrames.cs
- NamespaceTable.cs
- ParserContext.cs
- IPGlobalProperties.cs