Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -0,0 +1,105 @@
//------------------------------------------------------------------------------
// <copyright file="Constants.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Globalization;
using System.Web;
using System.Collections;
using System.Collections.Specialized;
using System.Web.UI;
using System.IO;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\Constants.uex' path='docs/doc[@for="Doctype"]/*' />
[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 enum Doctype {
/// <include file='doc\Constants.uex' path='docs/doc[@for="Doctype.NotSet"]/*' />
NotSet,
/// <include file='doc\Constants.uex' path='docs/doc[@for="Doctype.XhtmlBasic"]/*' />
XhtmlBasic,
/// <include file='doc\Constants.uex' path='docs/doc[@for="Doctype.XhtmlMobileProfile"]/*' />
XhtmlMobileProfile,
/// <include file='doc\Constants.uex' path='docs/doc[@for="Doctype.Wml20"]/*' />
Wml20
}
[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.")]
internal static class XhtmlConstants {
internal static readonly string CssQueryStringName = "_css";
internal static readonly string CacheStyleSheetValue = "application";
internal static readonly string CssSessionKey = CssQueryStringName;
internal static readonly string CssStateLocationAppSettingKey = "XhtmlCssState";
internal static readonly string CssMappedFileName = "xhtmlCss.axd";
internal static readonly StyleFilter Format = StyleFilter.None | StyleFilter.Italic | StyleFilter.Bold | StyleFilter.FontName | StyleFilter.FontSize | StyleFilter.BackgroundColor | StyleFilter.ForegroundColor;
internal static readonly StyleFilter Layout= StyleFilter.Wrapping | StyleFilter.Alignment;
internal static readonly StyleFilter All= XhtmlConstants.Format | XhtmlConstants.Layout;
internal static readonly string SessionKeyPrefix = "_s";
internal static readonly string PostedFromOtherFile = ".";
internal static Style DefaultStyle = new Style ();
internal static XhtmlStyleClass DefaultStyleClass = new XhtmlStyleClass(DefaultStyle, XhtmlConstants.All);
// Capabilities
internal static readonly string RequiresXhtmlCssSuppression = "requiresXhtmlCssSuppression";
internal static readonly string RequiresNewLineSuppression = "requiresNewLineSuppression";
internal static readonly string BreaksOnBlockElements = "breaksOnBlockElements";
internal static readonly string BreaksOnInlineElements = "breaksOnInlineElements";
internal static readonly string RequiresOnEnterForward = "requiresOnEnterForwardForCheckboxLists";
internal static readonly string SupportsBodyClassAttribute = "supportsBodyClassAttribute";
internal static readonly string SupportsUrlAttributeEncoding = "supportsUrlAttributeEncoding";
internal static readonly string InternalStyleConfigSetting = "supportsStyleElement";
internal static readonly string SupportsNoWrapStyle = "supportsNoWrapStyle";
// Custom attributes
internal static readonly string CssClassCustomAttribute = "cssclass";
internal static readonly string StyleSheetLocationCustomAttribute = "CssLocation";
internal static readonly string CssPagerClassCustomAttribute = "cssPagerClass";
internal static readonly string CssLabelClassCustomAttribute = "cssLabelClass";
internal static readonly string CssCommandClassCustomAttribute = "cssCommandClass";
internal static readonly string AccessKeyCustomAttribute = "accesskey";
internal static readonly string PagerNextAccessKeyCustomAttribute = "PagerNextAccessKey";
internal static readonly string PagerPreviousAccessKeyCustomAttribute = "PagerPrevAccessKey";
internal static readonly string TitleCustomAttribute = "title";
}
/// <include file='doc\Constants.uex' path='docs/doc[@for="StyleSheetLocation"]/*' />
[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 enum StyleSheetLocation {
/// <include file='doc\Constants.uex' path='docs/doc[@for="StyleSheetLocation.NotSet"]/*' />
NotSet,
/// <include file='doc\Constants.uex' path='docs/doc[@for="StyleSheetLocation.ApplicationCache"]/*' />
ApplicationCache,
/// <include file='doc\Constants.uex' path='docs/doc[@for="StyleSheetLocation.SessionState"]/*' />
SessionState,
/// <include file='doc\Constants.uex' path='docs/doc[@for="StyleSheetLocation.PhysicalFile"]/*' />
PhysicalFile,
/// <include file='doc\Constants.uex' path='docs/doc[@for="StyleSheetLocation.Internal"]/*' />
Internal,
/// <include file='doc\Constants.uex' path='docs/doc[@for="StyleSheetLocation.None // currently not used"]/*' />
None // currently not used
}
[Flags]
[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.")]
internal enum StyleFilter : int /* 32 bits */ {
None = 0x00000000,
Italic = 0x00000001,
Bold = 0x00000002,
FontName = 0x00000004,
FontSize = 0x00000008,
BackgroundColor = 0x00000010,
ForegroundColor = 0x00000020,
Wrapping = 0x00000040,
Alignment = 0x00000080
}
}

View File

@@ -0,0 +1,104 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicCommandAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Specialized;
using System.Security.Permissions;
using System.Web;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicCommandAdapter.uex' path='docs/doc[@for="XhtmlCommandAdapter"]/*' />
[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 XhtmlCommandAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicCommandAdapter.uex' path='docs/doc[@for="XhtmlCommandAdapter.Control"]/*' />
protected new Command Control {
get {
return base.Control as Command;
}
}
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 base.LoadPostData(key, data, controlPrivateData, out dataChanged);
}
/// <include file='doc\XhtmlBasicCommandAdapter.uex' path='docs/doc[@for="XhtmlCommandAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
// Note: Since XHTML Basic and MP do not include the script element, we ignore the
// Format==Link attribute as in CHTML.
ConditionalClearPendingBreak(writer);
string imageUrl = Control.ImageUrl;
if (imageUrl != null &&
imageUrl.Length > 0 &&
Device.SupportsImageSubmit) {
RenderAsInputTypeImage(writer);
}
else {
RenderAsInputTypeSubmit(writer);
}
}
private void RenderAsInputTypeImage(XhtmlMobileTextWriter writer) {
ConditionalEnterStyle(writer, Style);
writer.WriteBeginTag("input");
writer.WriteAttribute("type", "image");
writer.WriteAttribute("name", Control.UniqueID);
writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true);
writer.WriteAttribute("alt", Control.Text, true);
ConditionalRenderClassAttribute(writer);
ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
writer.Write("/>");
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreakAfterInline(writer);
ConditionalExitStyle(writer, Style);
}
private void RenderAsInputTypeSubmit(XhtmlMobileTextWriter writer){
ConditionalEnterStyle(writer, Style);
writer.WriteBeginTag("input");
writer.WriteAttribute("type", "submit");
writer.WriteAttribute("name", Control.UniqueID);
writer.WriteAttribute("value", Control.Text, true);
ConditionalRenderClassAttribute(writer);
ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
writer.Write("/>");
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreakAfterInline(writer);
ConditionalPopPhysicalCssClass(writer);
ConditionalExitStyle(writer, Style);
}
}
}

View File

@@ -0,0 +1,421 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicFormAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Globalization;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.Mobile;
using System.Web.Security;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
using System.Collections;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter"]/*' />
[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 XhtmlFormAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.Control"]/*' />
public new Form Control {
get {
return base.Control as Form;
}
}
/// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.Render"]/*' />
public override void Render (XhtmlMobileTextWriter writer) {
// Note: <head>, <body> rendered by page adapter, as in HTML case.
String formsAuthCookieName = FormsAuthentication.FormsCookieName;
if(!Device.SupportsRedirectWithCookie)
{
if(formsAuthCookieName != null && formsAuthCookieName.Length > 0)
{
HttpContext.Current.Response.Cookies.Remove(formsAuthCookieName);
}
}
writer.WriteBeginTag ("form");
writer.WriteAttribute ("id", Control.ClientID);
writer.WriteAttribute ("method", Control.Method.ToString().ToLower(CultureInfo.CurrentCulture));
writer.Write (" action=\"");
RenderPostbackUrl(writer);
if(Control.Action.Length > 0) {
if(Control.Action.IndexOf("?", StringComparison.Ordinal) != -1) {
writer.Write("&");
}
else {
writer.Write("?");
}
}
else {
writer.Write("?");
}
writer.Write(Page.UniqueFilePathSuffix);
if (Control.Method != FormMethod.Get &&
Control.Action.Length == 0) { // VSWhidbey 411176: We don't include QueryStringText if Action is explicitly set
String queryStringText = PreprocessQueryString(Page.QueryStringText);
if (queryStringText != null && queryStringText.Length > 0) {
String amp = (String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false" ? "&amp;" : "&";
writer.Write(amp);
if((String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false") {
writer.WriteEncodedText(queryStringText);
}
else {
writer.Write(queryStringText);
}
}
}
writer.WriteLine ("\">");
bool needDivStyle = (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
(String)Device["supportsBodyClassAttribute"] == "false";
if (!needDivStyle) {
if((String)Device["usePOverDiv"] == "true")
writer.WriteFullBeginTag("p");
else
writer.WriteFullBeginTag ("div");
}
else {
if((String)Device["usePOverDiv"] == "true")
writer.EnterStyle(Style, "p");
else
writer.EnterStyle (Style, "div");
}
RenderPostBackHeader (writer);
// Renders hidden variables for IPostBackDataHandlers which are
// not displayed due to pagination or secondary UI.
RenderOffPageVariables(writer, Control, Control.CurrentPage);
RenderChildren (writer);
if (!needDivStyle) {
if((String)Device["usePOverDiv"] == "true")
writer.WriteEndTag("p");
else
writer.WriteEndTag ("div");
}
else {
if((String)Device["usePOverDiv"] == "true")
writer.ExitStyle(Style);
else
writer.ExitStyle (Style);
}
writer.WriteEndTag ("form");
}
private void RenderPostBackHeader(XhtmlMobileTextWriter writer) {
bool postBack = Page.ActiveForm.Action.Length == 0;
RenderPageState(writer);
if (!postBack) {
writer.WriteHiddenField(PageAdapter.EventSourceKey, XhtmlConstants.PostedFromOtherFile);
}
else if (Page.ClientViewState == null) {
// The empty event source variable is used to identify a
// postback request. Value attribute is not needed, and some
// devices do not allow empty string value attributes.
if ((String)Device["requiresHiddenFieldValues"] != "true") {
writer.WriteHiddenField(PageAdapter.EventSourceKey);
}
else {
// Placeholder value is never used, just needed for some devices.
writer.WriteHiddenField(PageAdapter.EventSourceKey, PageAdapter.EventSourceKey);
}
}
RenderHiddenVariables(writer);
}
private void RenderHiddenVariables(XhtmlMobileTextWriter writer) {
if (Page.HasHiddenVariables()) {
String hiddenVariablePrefix = MobilePage.HiddenVariablePrefix;
foreach (DictionaryEntry entry in Page.HiddenVariables) {
if (entry.Value != null) {
writer.WriteHiddenField(hiddenVariablePrefix + (String)entry.Key,
(String)entry.Value);
}
}
}
}
private void RenderPageState (XhtmlMobileTextWriter writer) {
String viewState = Page.ClientViewState;
if (viewState != null) {
writer.WriteHiddenField (MobilePage.ViewStateID, viewState);
}
}
private void RenderChildren (XhtmlMobileTextWriter writer) {
if (SecondaryUIControl != null) {
RenderSecondaryUI (writer);
return;
}
bool pagerRendered = false;
if(Control.HasControls()) {
foreach(Control child in Control.Controls) {
if(Control.Footer == child) {
RenderPager(writer);
pagerRendered = true;
}
child.RenderControl(writer);
}
}
if(!pagerRendered) {
RenderPager(writer);
}
}
private void RenderSecondaryUI (XhtmlMobileTextWriter writer){
bool secondaryUIInHeaderOrFooter = IsControlInFormHeader (SecondaryUIControl)
|| IsControlInFormFooter (SecondaryUIControl);
SetControlPageRecursive(SecondaryUIControl, -1);
if (Control.Header != null && !secondaryUIInHeaderOrFooter) {
Control.Header.RenderControl (writer);
}
OpenSecondaryUIDivs(writer, SecondaryUIControl);
SecondaryUIControl.RenderControl (writer);
CloseSecondaryUIDivs(writer);
if (Control.Footer != null && !secondaryUIInHeaderOrFooter) {
Control.Footer.RenderControl (writer);
}
}
/////////////////////////////////////////////////////////////////////////
// SECONDARY UI SUPPORT
/////////////////////////////////////////////////////////////////////////
private MobileControl _secondaryUIControl;
private int _secondaryUIMode;
private int _secondaryUIDivsOpened = 0;
private void OpenSecondaryUIDivs(XhtmlMobileTextWriter writer, Control control) {
Control ctl = control.Parent as MobileControl;
while (ctl != null) {
String cssClass = ((IAttributeAccessor) ctl).GetAttribute(XhtmlConstants.CssClassCustomAttribute);
if (cssClass != null && cssClass. Length > 0) {
if((String)Device["usePOverDiv"] == "true") {
writer.WriteBeginTag("p");
}
else {
writer.WriteBeginTag("div");
}
writer.WriteAttribute("class", cssClass, true);
writer.WriteLine(">");
_secondaryUIDivsOpened++;
}
ctl = ctl.Parent as MobileControl;
}
}
private void CloseSecondaryUIDivs(XhtmlMobileTextWriter writer) {
for (int i = 0; i < _secondaryUIDivsOpened; i++) {
if((String)Device["usePOverDiv"] == "true") {
writer.WriteEndTag("p");
}
else {
writer.WriteEndTag("div");
}
writer.WriteLine();
}
}
internal int GetSecondaryUIMode(MobileControl control) {
return (control != null && _secondaryUIControl == control) ? _secondaryUIMode : NotSecondaryUI;
}
internal void SetSecondaryUIMode(MobileControl control, int mode) {
if (mode != NotSecondaryUI) {
if (_secondaryUIControl != null && _secondaryUIControl != control) {
throw new Exception(
SR.GetString(SR.FormAdapterMultiControlsAttemptSecondaryUI));
}
_secondaryUIControl = control;
_secondaryUIMode = mode;
return;
}
if (control == _secondaryUIControl) {
_secondaryUIControl = null;
}
}
internal MobileControl SecondaryUIControl {
get {
return _secondaryUIControl;
}
}
// Used for Secondary UI.
private bool IsControlInFormHeader(MobileControl control) {
return IsAncestor(Control.Header, control);
}
// Used for Secondary UI.
private bool IsControlInFormFooter(MobileControl control) {
return IsAncestor(Control.Footer, control);
}
private bool IsAncestor(MobileControl ancestor, MobileControl descendant) {
for (Control i = descendant; i != null; i = i.Parent) {
if (i == ancestor) {
return true;
}
}
return false;
}
/////////////////////////////////////////////////////////////////////////
// PAGINATION SUPPORT
/////////////////////////////////////////////////////////////////////////
/// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.RenderPager"]/*' />
protected virtual void RenderPager (XhtmlMobileTextWriter writer) {
PagerStyle pagerStyle = Control.PagerStyle;
int pageCount = Control.PageCount;
if (pageCount <= 1) {
return;
}
int page = Control.CurrentPage;
String text = pagerStyle.GetPageLabelText(page, pageCount);
if((page > 1) || (text.Length > 0) || (page < pageCount)) {
writer.WritePendingBreak();
ConditionalEnterStyle(writer, pagerStyle);
ConditionalEnterPagerSpan(writer);
}
if (page > 1) {
RenderPagerTag(writer, page - 1,
pagerStyle.GetPreviousPageText(page),
XhtmlConstants.PagerPreviousAccessKeyCustomAttribute);
writer.Write(" ");
}
if (text.Length > 0) {
writer.WriteEncodedText(text);
writer.Write(" ");
}
if (page < pageCount) {
RenderPagerTag(writer, page + 1,
pagerStyle.GetNextPageText(page),
XhtmlConstants.PagerNextAccessKeyCustomAttribute);
}
if((page > 1) || (text.Length > 0) || (page < pageCount)) {
ConditionalExitPagerSpan(writer);
ConditionalExitStyle(writer, pagerStyle);
writer.SetPendingBreak();
}
}
private bool _pagerCssSpanWritten = false;
private void ConditionalEnterPagerSpan(XhtmlMobileTextWriter writer) {
String cssClass = GetCustomAttributeValue(XhtmlConstants.CssPagerClassCustomAttribute);
if (CssLocation == StyleSheetLocation.PhysicalFile &&
cssClass != null &&
cssClass.Length > 0) {
writer.WriteBeginTag ("span");
writer.WriteAttribute("class", cssClass, true);
_pagerCssSpanWritten = true;
writer.Write(">");
}
}
private void ConditionalExitPagerSpan(XhtmlMobileTextWriter writer) {
if (_pagerCssSpanWritten) {
writer.WriteEndTag("span");
}
}
/// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.RenderPagerTag"]/*' />
protected virtual void RenderPagerTag(
XhtmlMobileTextWriter writer,
int pageToNavigate,
String text,
String accessKeyCustomAttribute) {
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);
ConditionalRenderCustomAttribute(writer, accessKeyCustomAttribute, XhtmlConstants.AccessKeyCustomAttribute);
writer.Write("/>");
}
private void RenderPostbackUrl(XhtmlMobileTextWriter writer) {
if ((String)Device["requiresAbsolutePostbackUrl"] == "true") {
RenderAbsolutePostbackUrl (writer);
return;
}
if (Control.Action.Length > 0) {
String url = Control.ResolveUrl(PreprocessQueryString(Control.Action));
writer.Write(url);
}
else {
writer.WriteEncodedUrl(Page.RelativeFilePath);
}
}
private void RenderAbsolutePostbackUrl(XhtmlMobileTextWriter writer) {
String url = PreprocessQueryString(Control.Action);
if (url.Length > 0) {
// Not only do we need to resolve the URL, but we need to make it absolute.
url = Page.MakePathAbsolute(Control.ResolveUrl(url));
writer.Write(url);
}
else {
writer.WriteEncodedUrl(Page.AbsoluteFilePath);
}
}
private static void SetControlPageRecursive(Control control, int page)
{
MobileControl mc = control as MobileControl;
if(mc != null)
{
mc.FirstPage = page;
mc.LastPage = page;
}
if (control.HasControls())
{
foreach (Control child in control.Controls)
{
MobileControl mobileChild = child as MobileControl;
if (mobileChild != null)
{
mobileChild.FirstPage = page;
mobileChild.LastPage = page;
}
else
{
SetControlPageRecursive(child, page);
}
}
}
}
}
}

View File

@@ -0,0 +1,93 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicImageAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Security.Permissions;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter"]/*' />
[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 XhtmlImageAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter.Control"]/*' />
protected new Image Control {
get {
return base.Control as Image;
}
}
/// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
string target = Control.NavigateUrl;
ConditionalClearPendingBreak(writer);
Style style = Style;
StyleFilter filter = writer.CurrentStyleClass.GetFilter(style);
if ((filter & XhtmlConstants.Layout) != 0) {
ConditionalEnterLayout(writer, style);
}
if(target != null && target.Length > 0) {
String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute);
String title = GetCustomAttributeValue(XhtmlConstants.TitleCustomAttribute);
RenderBeginLink(writer, target, accessKey, style, cssClass, title);
}
else{
ConditionalEnterFormat(writer, style);
ConditionalRenderOpeningSpanElement(writer);
}
String controlIU = Control.ImageUrl;
if(controlIU == null || controlIU.Length == 0) {
writer.WriteEncodedText(Control.AlternateText);
}
else {
RenderImage(writer);
}
ConditionalSetPendingBreakAfterInline(writer);
if(target != null && target.Length > 0) {
RenderEndLink(writer);
}
else {
ConditionalRenderClosingSpanElement(writer);
ConditionalExitFormat(writer, style);
}
if ((filter & XhtmlConstants.Layout) != 0) {
ConditionalExitLayout(writer, style);
}
}
/// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter.RenderImage"]/*' />
protected virtual void RenderImage(XhtmlMobileTextWriter writer) {
String source = Control.ImageUrl;
writer.WriteBeginTag("img");
if(source != null && source.Length > 0) {
source = Page.Server.UrlPathEncode(Control.ResolveUrl(source.Trim()));
writer.WriteAttribute("src", source, true);
writer.AddResource(source);
}
String alternateText = Control.AlternateText;
if (alternateText == null || alternateText.Length == 0) {
alternateText = " "; // ASURT 143759 and VSWhidbey 78593
}
writer.WriteAttribute("alt", alternateText, true);
// Review: Html adapter writes border=0 attribute, but don't need this here?
writer.Write(" />");
}
}
}

View File

@@ -0,0 +1,46 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicLabelAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.Security.Permissions;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicLabelAdapter.uex' path='docs/doc[@for="XhtmlLabelAdapter"]/*' />
[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 XhtmlLabelAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicLabelAdapter.uex' path='docs/doc[@for="XhtmlLabelAdapter.Control"]/*' />
public new Label Control {
get {
return base.Control as Label;
}
}
/// <include file='doc\XhtmlBasicLabelAdapter.uex' path='docs/doc[@for="XhtmlLabelAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
// ConditionalClearCachedEndTag() is for a device special case.
ConditionalClearCachedEndTag(writer, Control.Text);
ConditionalEnterStyle(writer, Style);
ConditionalRenderOpeningSpanElement(writer);
writer.WritePendingBreak();
writer.WriteEncodedText(Control.Text);
writer.WriteLine ();
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreak(writer);
ConditionalRenderClosingSpanElement(writer);
ConditionalExitStyle(writer, Style);
}
}
}

View File

@@ -0,0 +1,48 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicLinkAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Security.Permissions;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicLinkAdapter.uex' path='docs/doc[@for="XhtmlLinkAdapter"]/*' />
[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 XhtmlLinkAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicLinkAdapter.uex' path='docs/doc[@for="XhtmlLinkAdapter.Control"]/*' />
protected new Link Control {
get {
return base.Control as Link;
}
}
/// <include file='doc\XhtmlBasicLinkAdapter.uex' path='docs/doc[@for="XhtmlLinkAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
ConditionalClearPendingBreak(writer);
ConditionalEnterStyle(writer, Style);
String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute);
RenderBeginLink(writer, Control.NavigateUrl, accessKey, Style, cssClass);
String controlText = Control.Text;
writer.WriteEncodedText(controlText == null || controlText.Length == 0 ? Control.NavigateUrl : controlText);
RenderEndLink(writer);
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreakAfterInline(writer);
ConditionalExitStyle(writer, Style);
}
}
}

View File

@@ -0,0 +1,134 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicListAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Globalization;
using System.Security.Permissions;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicListAdapter.uex' path='docs/doc[@for="XhtmlListAdapter"]/*' />
[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 XhtmlListAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicListAdapter.uex' path='docs/doc[@for="XhtmlListAdapter.Control"]/*' />
protected new List Control {
get {
return base.Control as List;
}
}
/// <include file='doc\XhtmlBasicListAdapter.uex' path='docs/doc[@for="XhtmlListAdapter.Render"]/*' />
public override void Render (XhtmlMobileTextWriter writer) {
if (Control.HasControls()) {
ConditionalRenderOpeningDivElement(writer);
RenderChildren (writer);
ConditionalRenderClosingDivElement(writer);
return;
}
if (Control.Items.Count != 0) {
ClearPendingBreakIfDeviceBreaksOnBlockLevel(writer); // we are writing a block level element in all cases.
}
ConditionalEnterLayout(writer, Style);
RenderList (writer);
ConditionalExitLayout(writer, Style);
}
/// <include file='doc\XhtmlBasicListAdapter.uex' path='docs/doc[@for="XhtmlListAdapter.RenderList"]/*' />
protected virtual void RenderList (XhtmlMobileTextWriter writer) {
MobileListItemCollection items = Control.Items;
if (items.Count == 0) {
return;
}
ListDecoration decoration = Control.Decoration;
// Review: Consider replacing switch.
switch (decoration) {
case ListDecoration.Bulleted:
RenderBulletedList (writer);
break;
case ListDecoration.Numbered:
RenderNumberedList (writer);
break;
default:
if (!Device.Tables) {
RenderUndecoratedList(writer);
return;
}
RenderTableList (writer);
break;
}
}
private void RenderBulletedList (XhtmlMobileTextWriter writer) {
RenderOpeningListTag(writer, "ul");
RenderListBody (writer, "<li>", "</li>");
RenderClosingListTag (writer, "ul");
}
private void RenderTableList (XhtmlMobileTextWriter writer) {
RenderOpeningListTag(writer, "table");
RenderListBody (writer, "<tr><td>", "</td></tr>");
RenderClosingListTag(writer, "table");
}
private void RenderNumberedList (XhtmlMobileTextWriter writer) {
RenderOpeningListTag(writer, "ol");
RenderListBody (writer, "<li>", "</li>");
RenderClosingListTag(writer, "ol");
}
private void RenderListBody (XhtmlMobileTextWriter writer, String itemPrefix, String itemSuffix) {
int pageStart = Control.FirstVisibleItemIndex;
int pageSize = Control.VisibleItemCount;
for (int i = 0; i < pageSize; i++) {
MobileListItem item = Control.Items[pageStart + i];
writer.Write (itemPrefix);
RenderListItem (writer, item);
writer.WriteLine(itemSuffix);
}
}
private void RenderUndecoratedList (XhtmlMobileTextWriter writer) {
String br = writer.UseDivsForBreaks ? "</div><div>" : "<br/>";
if((string)Device["usePOverDiv"] == "true")
br = "<br/>";
RenderListBody (writer, "", br);
}
private void RenderListItem (XhtmlMobileTextWriter writer, MobileListItem item) {
String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute);
String cssClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute);
if (Control.ItemsAsLinks) {
RenderBeginLink (writer, item.Value, accessKey, Style, cssClass);
writer.WriteEncodedText (item.Text);
RenderEndLink (writer);
}
else if (Control.HasItemCommandHandler) {
RenderPostBackEventAsAnchor (writer,
item.Index.ToString(CultureInfo.InvariantCulture) /*event argument*/,
item.Text /*link text*/,
accessKey,
Style,
cssClass);
}
else {
writer.WriteEncodedText (item.Text);
}
}
}
}

View File

@@ -0,0 +1,47 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicLiteralTextAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.Security.Permissions;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
using System;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicLiteralTextAdapter.uex' path='docs/doc[@for="XhtmlLiteralTextAdapter"]/*' />
[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 XhtmlLiteralTextAdapter : XhtmlControlAdapter
{
/// <include file='doc\XhtmlBasicLiteralTextAdapter.uex' path='docs/doc[@for="XhtmlLiteralTextAdapter.Control"]/*' />
protected new LiteralText Control {
get {
return base.Control as LiteralText;
}
}
/// <include file='doc\XhtmlBasicLiteralTextAdapter.uex' path='docs/doc[@for="XhtmlLiteralTextAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
// ConditionalClearCachedEndTag() is for a device special case.
ConditionalClearCachedEndTag(writer, Control.Text);
String text = Control.PagedText;
ConditionalEnterStyle(writer, Style);
ConditionalRenderOpeningSpanElement(writer);
writer.WritePendingBreak();
writer.WriteEncodedText(text);
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreak(writer);
ConditionalRenderClosingSpanElement(writer);
ConditionalExitStyle(writer, Style);
}
}
}

View File

@@ -0,0 +1,47 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicPanelAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Security.Permissions;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicPanelAdapter.uex' path='docs/doc[@for="XhtmlPanelAdapter"]/*' />
[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 XhtmlPanelAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicPanelAdapter.uex' path='docs/doc[@for="XhtmlPanelAdapter.Control"]/*' />
protected new Panel Control {
get {
return base.Control as Panel;
}
}
/// <include file='doc\XhtmlBasicPanelAdapter.uex' path='docs/doc[@for="XhtmlPanelAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
if (Control.Content != null) {
Control.Content.RenderControl(writer);
}
else {
ConditionalEnterStyle(writer, Style);
ConditionalRenderOpeningDivElement(writer);
RenderChildren(writer);
ConditionalSetPendingBreak(writer);
ConditionalRenderClosingDivElement(writer);
ConditionalExitStyle(writer, Style);
}
}
}
}

View File

@@ -0,0 +1,115 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicPhoneCallAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Globalization;
using System.Security.Permissions;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicPhoneCallAdapter.uex' path='docs/doc[@for="XhtmlPhoneCallAdapter"]/*' />
[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 XhtmlPhoneCallAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicPhoneCallAdapter.uex' path='docs/doc[@for="XhtmlPhoneCallAdapter.Control"]/*' />
protected new PhoneCall Control {
get {
return base.Control as PhoneCall;
}
}
/// <include file='doc\XhtmlBasicPhoneCallAdapter.uex' path='docs/doc[@for="XhtmlPhoneCallAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer)
{
ConditionalClearPendingBreak(writer);
Style style = Style;
StyleFilter filter = writer.CurrentStyleClass.GetFilter(style);
if ((filter & XhtmlConstants.Layout) != 0) {
ConditionalEnterLayout(writer, style);
}
if (Device.CanInitiateVoiceCall) {
String text = Control.Text;
String phoneNumber = Control.PhoneNumber;
if (text == null || text.Length == 0) {
text = phoneNumber;
}
writer.WriteBeginTag("a");
if ((String)Device["supportsWtai"] == "true") {
writer.Write(" href=\"wtai://wp/mc;");
}
else {
writer.Write(" href=\"tel:");
}
foreach (char ch in phoneNumber) {
if (ch >= '0' && ch <= '9' || ch == '#' || ch == '+') {
writer.Write(ch);
}
}
writer.Write("\"");
ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
if (CssLocation != StyleSheetLocation.PhysicalFile) {
String className = writer.GetCssFormatClassName(style);
if (className != null) {
writer.WriteAttribute ("class", className);
}
}
else if (cssClass != null && cssClass.Length > 0) {
writer.WriteAttribute ("class", cssClass, true /* encode */);
}
writer.Write(">");
writer.WriteEncodedText(text);
writer.WriteEndTag("a");
ConditionalSetPendingBreakAfterInline(writer);
}
else {
// Format the text string based on properties
String text = String.Format(
CultureInfo.CurrentCulture,
Control.AlternateFormat,
Control.Text,
Control.PhoneNumber);
String url = Control.AlternateUrl;
// If URI specified, create a link. Otherwise, only text is displayed.
if (url != null && url.Length > 0) {
String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute);
RenderBeginLink(writer, url, accessKey, style, cssClass);
writer.WriteEncodedText(text);
RenderEndLink(writer);
ConditionalSetPendingBreakAfterInline(writer);
}
else {
writer.WritePendingBreak();
ConditionalEnterFormat(writer, style);
ConditionalRenderOpeningSpanElement(writer);
writer.WriteEncodedText(text);
ConditionalRenderClosingSpanElement(writer);
ConditionalExitFormat(writer, style);
ConditionalSetPendingBreak(writer);
}
}
if ((filter & XhtmlConstants.Layout) != 0) {
ConditionalExitLayout(writer, style);
}
}
}
}

View File

@@ -0,0 +1,295 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicSelectionListAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Globalization;
using System.Security.Permissions;
using System.Web.UI;
using System.Collections.Specialized;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
using System.Text.RegularExpressions;
using System.Text;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicSelectionListAdapter.uex' path='docs/doc[@for="XhtmlSelectionListAdapter"]/*' />
[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 XhtmlSelectionListAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicSelectionListAdapter.uex' path='docs/doc[@for="XhtmlSelectionListAdapter.Control"]/*' />
protected new SelectionList Control {
get {
return base.Control as SelectionList;
}
}
/// <include file='doc\XhtmlBasicSelectionListAdapter.uex' path='docs/doc[@for="XhtmlSelectionListAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
// Assumption: XhtmlBasic devices all support tables (conforming to spec).
if (Control.Items.Count == 0) {
return;
}
if ((String) Device[XhtmlConstants.RequiresOnEnterForward] == "true") {
AddOnEnterForward(writer);
}
int selectedIndex = Control.SelectedIndex;
switch(Control.SelectType) {
case ListSelectType.DropDown:
case ListSelectType.ListBox:
case ListSelectType.MultiSelectListBox:
RenderSelectElement (writer);
break;
case ListSelectType.Radio:
case ListSelectType.CheckBox:
RenderInputElementSet (writer);
break;
}
}
private void AddOnEnterForward(XhtmlMobileTextWriter writer) {
if (Control.SelectType == ListSelectType.CheckBox) {
// ASURT 142732
writer.AddOnEnterForwardSetVar(Control.UniqueID);
return;
}
bool firstIndex = true;
StringBuilder builder = new StringBuilder();
for (int i = 0; i < Control.Items.Count; i++) {
if (Control.Items[i].Selected) {
if (!firstIndex) {
builder.Append(";");
}
builder.Append(i.ToString(CultureInfo.InvariantCulture));
firstIndex = false;
}
}
writer.AddOnEnterForwardSetVar(Control.UniqueID, builder.ToString());
}
/// <include file='doc\XhtmlBasicSelectionListAdapter.uex' path='docs/doc[@for="XhtmlSelectionListAdapter.LoadPostData"]/*' />
public override bool LoadPostData (String key,
NameValueCollection data,
Object controlPrivateData,
out bool dataChanged) {
String[] selectedItems = data.GetValues(key);
// If no post data is included, and the control is either not visible, or
// not on active form, this call should be ignored (the lack of post data
// is not due to there being no selection, but due to there being no
// markup rendered that could generate the post data).
if (selectedItems == null &&
(!Control.Visible || Control.Form != Control.MobilePage.ActiveForm)) {
dataChanged = false;
return true;
}
// Case where nothing is selected.
if(selectedItems == null ||
(selectedItems.Length == 1 && (selectedItems[0] == null || selectedItems[0].Length == 0))) {
selectedItems = new String[] {};
}
// multiselect case with more than one selection.
if(selectedItems.Length == 1 && selectedItems[0].IndexOf(';') > -1) {
String selected = selectedItems[0];
// Eliminate trailing semicolon, if there is one.
selected = Regex.Replace(selected, ";$", "");
selectedItems = Regex.Split(selected, ";");
}
int[] selectedItemIndices = new int[selectedItems.Length];
// Note: controlPrivateData is selected indices from the viewstate.
int[] originalSelectedIndices = (int[])controlPrivateData;
dataChanged = false;
// If SelectType is DropDown && nothing was selected, select
// first elt. (Non-mobile DropDown does same by getting SelectedIndex).
if(Control.SelectType == ListSelectType.DropDown &&
originalSelectedIndices.Length == 0 &&
Control.Items.Count > 0) {
Control.Items[0].Selected = true;
originalSelectedIndices = new int[]{0};
}
for(int i = 0; i < selectedItems.Length; i++) {
selectedItemIndices[i] = Int32.Parse(selectedItems[i], CultureInfo.InvariantCulture);
}
// Do not assume posted selected indices are ascending.
// We do know originalSelectedIndices are ascending.
Array.Sort(selectedItemIndices);
// Check whether selections have changed.
if(selectedItemIndices.Length != originalSelectedIndices.Length) {
dataChanged = true;
}
else {
for(int i = 0; i < selectedItems.Length; i++) {
if(selectedItemIndices[i] != originalSelectedIndices[i]) {
dataChanged = true;
}
}
}
for (int i = 0; i < Control.Items.Count; i++) {
Control.Items[i].Selected = false;
}
for(int i = 0; i < selectedItemIndices.Length; i++) {
Control.Items[selectedItemIndices[i]].Selected = true;
}
return true;
}
void RenderInputElementSet (XhtmlMobileTextWriter writer) {
string wrappingTag = Device.Tables ? "table" :
(((string)Device["usePOverDiv"] == "true") ? "p" : "div");
ListSelectType selectType = Control.SelectType;
MobileListItemCollection items = Control.Items;
// Review: We always render a table. Should we optimize away the table tags when the alignment is left?
String selectTypeString =
(selectType == ListSelectType.Radio) ?
"radio" :
"checkbox";
ClearPendingBreakIfDeviceBreaksOnBlockLevel(writer); // Since we are writing a block-level element in all cases.
ConditionalEnterLayout(writer, Style);
RenderOpeningListTag(writer, wrappingTag);
for(int itemIndex = 0; itemIndex < items.Count; itemIndex++) {
MobileListItem item = items[itemIndex];
if (Device.Tables) {
writer.WriteFullBeginTag("tr");
writer.WriteFullBeginTag("td");
}
writer.WriteBeginTag("input");
writer.WriteAttribute("type", selectTypeString);
writer.WriteAttribute("name", Control.UniqueID);
WriteItemValueAttribute(writer, itemIndex, item.Value);
String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute);
if (accessKey != null && accessKey.Length > 0) {
writer.WriteAttribute("accesskey", accessKey, true);
}
// Assumption: Device.SupportsUncheck is always true for Xhtml devices.
if (item.Selected &&
(Control.IsMultiSelect || itemIndex == Control.SelectedIndex)) {
writer.Write(" checked=\"checked\"/>");
}
else {
writer.Write("/>");
}
writer.WriteEncodedText(item.Text);
if (Device.Tables) {
writer.WriteEndTag("td");
}
if((string)Device["usePOverDiv"] == "true" || !Device.Tables) {
writer.Write("<br/>");
}
if (Device.Tables) {
writer.WriteEndTag("tr");
}
}
RenderClosingListTag(writer, wrappingTag);
ConditionalExitLayout(writer, Style);
}
void RenderSelectElement (XhtmlMobileTextWriter writer) {
if ((String)Device["supportsSelectFollowingTable"] == "false" && writer.CachedEndTag == "table") {
writer.Write("&nbsp;");
}
ConditionalEnterStyle(writer, Style);
writer.WriteBeginTag ("select");
if (Control.SelectType == ListSelectType.MultiSelectListBox) {
writer.WriteAttribute ("multiple", "multiple");
}
if (Control.SelectType == ListSelectType.ListBox || Control.SelectType == ListSelectType.MultiSelectListBox) {
writer.WriteAttribute ("size", Control.Rows.ToString(CultureInfo.InvariantCulture));
}
writer.WriteAttribute ("name", Control.UniqueID);
ConditionalRenderClassAttribute(writer);
writer.Write (">");
for (int itemIndex = 0; itemIndex < Control.Items.Count; itemIndex++) {
MobileListItem item = Control.Items[itemIndex];
writer.WriteBeginTag ("option");
WriteItemValueAttribute (writer, itemIndex, item.Value);
if (item.Selected && (Control.IsMultiSelect || itemIndex == Control.SelectedIndex)) {
writer.Write (" selected=\"selected\">");
}
else {
writer.Write (">");
}
writer.WriteEncodedText (item.Text);
writer.WriteLine ("</option>");
}
ConditionalSetPendingBreak(writer);
writer.WriteEndTag ("select");
writer.WriteLine ();
ConditionalPopPhysicalCssClass(writer);
ConditionalExitStyle(writer, Style);
}
private void WriteItemValueAttribute (XhtmlMobileTextWriter writer, int index, String value) {
String controlFormAction = Control.Form.Action;
if (controlFormAction == null || controlFormAction.Length == 0) {
writer.WriteAttribute ("value", index.ToString(CultureInfo.InvariantCulture));
}
else {
writer.WriteAttribute ("value", value, true /*encode*/);
}
}
/// <include file='doc\XhtmlBasicSelectionListAdapter.uex' path='docs/doc[@for="XhtmlSelectionListAdapter.RenderAsHiddenInputField"]/*' />
protected override void RenderAsHiddenInputField(XhtmlMobileTextWriter writer) {
// Optimization - if viewstate is enabled for this control, and the
// postback returns to this page, we just let it do the trick.
// One catch though - if the control is multiselect, it always
// interprets return values, so we do need to write out.
if (Control.IsMultiSelect || Control.Form.Action.Length > 0 || !IsViewStateEnabled()) {
String uniqueID = Control.UniqueID;
MobileListItemCollection items = Control.Items;
for (int i = 0; i < items.Count; i++) {
if (items[i].Selected) {
writer.WriteHiddenField(uniqueID, i.ToString(CultureInfo.InvariantCulture));
}
}
}
}
private bool IsViewStateEnabled() {
Control ctl = Control;
while (ctl != null) {
if (!ctl.EnableViewState) {
return false;
}
ctl = ctl.Parent;
}
return true;
}
}
}

View File

@@ -0,0 +1,113 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicTextBoxAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Security.Permissions;
using System.Web.UI;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
using System.Globalization;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter"]/*' />
[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 XhtmlTextBoxAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter.Control"]/*' />
public new TextBox Control {
get {
return base.Control as TextBox;
}
}
// Used for optimization in RenderAsHiddenField.
private String _staticValue;
/// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter.OnInit"]/*' />
public override void OnInit(EventArgs e) {
_staticValue = Control.Text;
base.OnInit(e);
}
/// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
ConditionalClearPendingBreak(writer);
ConditionalEnterStyle(writer, Style);
ConditionalRenderOpeningSpanElement(writer);
if ((String) Device[XhtmlConstants.RequiresOnEnterForward] == "true") {
writer.AddOnEnterForwardSetVar(Control.UniqueID, Control.Text);
}
writer.WriteBeginTag("input");
writer.WriteAttribute("name", Control.UniqueID);
ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
String controlText = Control.Text;
if (controlText != null && controlText.Length > 0 && !Control.Password) {
writer.Write(" value=\"");
writer.WriteEncodedText(controlText);
writer.Write("\"");
}
if (Control.Size > 0) {
writer.WriteAttribute("size", Control.Size.ToString(CultureInfo.InvariantCulture));
}
if (Control.MaxLength > 0) {
writer.WriteAttribute("maxlength", Control.MaxLength.ToString(CultureInfo.InvariantCulture));
}
String requiresType = Device["requiresInputTypeAttribute"];
if (Control.Password) {
writer.WriteAttribute("type", "password");
}
// InvariantCulture not needed, but included for best practices.
else if (requiresType != null && String.Equals(requiresType, "true", StringComparison.OrdinalIgnoreCase)) {
writer.WriteAttribute("type", "text");
}
writer.Write("/>");
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreakAfterInline(writer);
ConditionalRenderClosingSpanElement(writer);
ConditionalExitStyle(writer, Style);
}
/// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter.RenderAsHiddenInputField"]/*' />
protected override void RenderAsHiddenInputField(XhtmlMobileTextWriter writer) {
// Optimization - if viewstate is enabled for this control, and the
// postback returns to this page, we just let it do the trick.
if (Control.Form.Action.Length > 0 || (!IsViewStateEnabled() && Control.Text != _staticValue)) {
writer.WriteHiddenField(Control.UniqueID, Control.Text);
}
}
private bool IsViewStateEnabled() {
Control ctl = Control;
while (ctl != null) {
if (!ctl.EnableViewState) {
return false;
}
ctl = ctl.Parent;
}
return true;
}
}
}

View File

@@ -0,0 +1,101 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicTextViewAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Security.Permissions;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicTextViewAdapter.uex' path='docs/doc[@for="XhtmlTextViewAdapter"]/*' />
[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 XhtmlTextViewAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicTextViewAdapter.uex' path='docs/doc[@for="XhtmlTextViewAdapter.Control"]/*' />
protected new TextView Control {
get {
return base.Control as TextView;
}
}
/// <include file='doc\XhtmlBasicTextViewAdapter.uex' path='docs/doc[@for="XhtmlTextViewAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
int beginElement = Control.FirstVisibleElementIndex;
int beginOffset = Control.FirstVisibleElementOffset;
int endElement = Control.LastVisibleElementIndex;
int endOffset = Control.LastVisibleElementOffset;
// ConditionalClearCachedEndTag() is for a device special case.
ConditionalClearCachedEndTag(writer, Control.Text);
ConditionalEnterStyle(writer, Style);
ConditionalRenderOpeningSpanElement(writer);
writer.WritePendingBreak();
for(int i = beginElement; i <= endElement; i++) {
int begin = (i == beginElement) ? beginOffset : 0;
int end;
if (i == endElement) {
if (endOffset <= begin) {
break;
}
end = endOffset;
}
else {
end = -1;
}
RenderElement(writer, i, begin, end);
}
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreak(writer);
ConditionalRenderClosingSpanElement(writer);
ConditionalExitStyle(writer, Style);
}
/// <include file='doc\XhtmlBasicTextViewAdapter.uex' path='docs/doc[@for="XhtmlTextViewAdapter.RenderElement"]/*' />
public void RenderElement(XhtmlMobileTextWriter writer, int index, int beginSubstring, int endSubstring) {
TextViewElement element = Control.GetElement(index);
writer.WritePendingBreak();
if (endSubstring == -1) {
endSubstring = element.Text.Length;
}
String text = element.Text;
if (beginSubstring > 0 || endSubstring < text.Length) {
text = text.Substring(beginSubstring, endSubstring - beginSubstring);
}
BooleanOption prevBold = Style.Font.Bold;
BooleanOption prevItalic = Style.Font.Italic;
if (element.IsBold) {
Style.Font.Bold = BooleanOption.True;
}
if (element.IsItalic) {
Style.Font.Italic = BooleanOption.True;
}
ConditionalEnterStyle(writer, Style);
if (element.Url != null) {
RenderBeginLink(writer, element.Url);
writer.WriteEncodedText(text);
RenderEndLink(writer);
}
else {
writer.WriteEncodedText(text);
}
if (element.BreakAfter) {
writer.SetPendingBreak();
}
ConditionalExitStyle(writer, Style);
Style.Font.Bold = prevBold;
Style.Font.Italic = prevItalic;
}
}
}

View File

@@ -0,0 +1,101 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicValidationSummary.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Diagnostics;
using System.Globalization;
using System.Security.Permissions;
using System.Web.UI;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicValidationSummaryAdapter.uex' path='docs/doc[@for="XhtmlValidationSummaryAdapter"]/*' />
[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 XhtmlValidationSummaryAdapter : XhtmlControlAdapter {
private List _list; // to paginate error messages
private Link _link; // to go back to the form validated by this control
/// <include file='doc\XhtmlBasicValidationSummaryAdapter.uex' path='docs/doc[@for="XhtmlValidationSummaryAdapter.Control"]/*' />
protected new ValidationSummary Control {
get {
return base.Control as ValidationSummary;
}
}
/// <include file='doc\XhtmlBasicValidationSummaryAdapter.uex' path='docs/doc[@for="XhtmlValidationSummaryAdapter.OnInit"]/*' />
public override void OnInit(EventArgs e) {
// Create child controls to help on rendering
_list = new List();
Control.Controls.Add(_list);
_link = new Link();
Control.Controls.Add(_link);
}
/// <include file='doc\XhtmlBasicValidationSummaryAdapter.uex' path='docs/doc[@for="XhtmlValidationSummaryAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
String[] errorMessages = null;
if (Control.Visible) {
errorMessages = Control.GetErrorMessages();
}
if (errorMessages != null) {
ConditionalEnterStyle(writer, Style, "div");
ConditionalRenderOpeningDivElement(writer);
if (Control.HeaderText.Length > 0) {
// ConditionalClearCachedEndTag() is for a device special case.
ConditionalClearCachedEndTag(writer, Control.HeaderText);
writer.WriteEncodedText (Control.HeaderText);
}
ArrayList arr = new ArrayList();
foreach (String errorMessage in errorMessages) {
Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages");
arr.Add(errorMessage);
}
_list.Decoration = ListDecoration.Bulleted;
_list.DataSource = arr;
_list.DataBind();
if (String.Compare(Control.FormToValidate, Control.Form.UniqueID, true, CultureInfo.CurrentCulture) != 0) {
_link.NavigateUrl = Constants.FormIDPrefix + Control.FormToValidate;
String controlBackLabel = Control.BackLabel;
_link.Text = controlBackLabel == null || controlBackLabel.Length == 0 ? GetDefaultLabel(BackLabel) : controlBackLabel;
// Summary writes its own break so last control should write one.
_link.BreakAfter = false;
((IAttributeAccessor)_link).SetAttribute(XhtmlConstants.AccessKeyCustomAttribute, GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute));
}
else {
_link.Visible = false;
// Summary writes its own break so last control should write one.
_list.BreakAfter = false;
}
// Render the child controls to display error message list and a
// link for going back to the Form that is having error
RenderChildren(writer);
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreak(writer);
ConditionalRenderClosingDivElement(writer);
ConditionalExitStyle(writer, Style);
}
}
}
}

View File

@@ -0,0 +1,59 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlBasicValidatorAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Security.Permissions;
using System.Web.Mobile;
using System.Web.UI.MobileControls;
using System.Web.UI.MobileControls.Adapters;
using WebControls = System.Web.UI.WebControls;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlBasicValidatorAdapter.uex' path='docs/doc[@for="XhtmlValidatorAdapter"]/*' />
[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 XhtmlValidatorAdapter : XhtmlControlAdapter {
/// <include file='doc\XhtmlBasicValidatorAdapter.uex' path='docs/doc[@for="XhtmlValidatorAdapter.Control"]/*' />
protected new BaseValidator Control {
get {
return base.Control as BaseValidator;
}
}
/// <include file='doc\XhtmlBasicValidatorAdapter.uex' path='docs/doc[@for="XhtmlValidatorAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
if (!Control.IsValid && Control.Display != WebControls.ValidatorDisplay.None) {
ConditionalEnterStyle(writer, Style);
ConditionalRenderOpeningSpanElement(writer);
writer.WritePendingBreak();
String controlText = Control.Text;
String controlErrorMessage = Control.ErrorMessage;
if (controlText != null & controlText.Length > 0) {
// ConditionalClearCachedEndTag() is for a device special case.
ConditionalClearCachedEndTag(writer, Control.Text);
writer.WriteEncodedText (Control.Text);
}
else if (controlErrorMessage != null && controlErrorMessage.Length > 0) {
ConditionalClearCachedEndTag(writer, Control.ErrorMessage);
writer.WriteEncodedText (Control.ErrorMessage);
}
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreak(writer);
ConditionalRenderClosingSpanElement(writer);
ConditionalExitStyle(writer, Style);
}
}
}
}

View File

@@ -0,0 +1,57 @@
//------------------------------------------------------------------------------
// <copyright file="XhtmlCssHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Security.Permissions;
using System.Web;
using System.Web.SessionState;
using System.Web.UI.MobileControls.Adapters;
#if COMPILING_FOR_SHIPPED_SOURCE
namespace System.Web.UI.MobileControls.ShippedAdapterSource.XhtmlAdapters
#else
namespace System.Web.UI.MobileControls.Adapters.XhtmlAdapters
#endif
{
/// <include file='doc\XhtmlCssHandler.uex' path='docs/doc[@for="XhtmlCssHandler"]/*' />
[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 XhtmlCssHandler : IHttpHandler, IRequiresSessionState {
/// <include file='doc\XhtmlCssHandler.uex' path='docs/doc[@for="XhtmlCssHandler.ProcessRequest"]/*' />
public void ProcessRequest (HttpContext context) {
String cssQueryStringValue = (String) context.Request.QueryString[XhtmlConstants.CssQueryStringName];
String response;
if (cssQueryStringValue != null) {
// Recall that Page.Cache is application level
if (cssQueryStringValue.StartsWith(XhtmlConstants.SessionKeyPrefix, StringComparison.Ordinal)) {
response = (String) context.Session[cssQueryStringValue];
}
else {
response = (String) context.Cache[cssQueryStringValue];
}
context.Response.ContentType="text/css";
}
else {
throw new HttpException (404, SR.GetString(
SR.XhtmlCssHandler_IdNotPresent));
}
if (response == null) {
throw new HttpException (404, SR.GetString(
SR.XhtmlCssHandler_StylesheetNotFound));
}
context.Response.Write (response);
}
/// <include file='doc\XhtmlCssHandler.uex' path='docs/doc[@for="XhtmlCssHandler.IsReusable"]/*' />
public bool IsReusable {
get {
return true;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More