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,264 @@
//------------------------------------------------------------------------------
// <copyright file="AccessDataSource.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Design;
using System.IO;
using System.Text;
using System.Web.Caching;
using System.Web.UI;
/// <devdoc>
/// Allows a user to create a declarative connection to an Access database in a .aspx page.
/// </devdoc>
[
Designer("System.Web.UI.Design.WebControls.AccessDataSourceDesigner, " + AssemblyRef.SystemDesign),
ToolboxBitmap(typeof(AccessDataSource)),
WebSysDescription(SR.AccessDataSource_Description),
WebSysDisplayName(SR.AccessDataSource_DisplayName)
]
public class AccessDataSource : SqlDataSource {
private const string OleDbProviderName = "System.Data.OleDb";
private const string JetProvider = "Microsoft.Jet.OLEDB.4.0";
private const string Access2007Provider = "Microsoft.ACE.OLEDB.12.0";
private const string Access2007FileExtension = ".accdb";
private FileDataSourceCache _cache;
private string _connectionString;
private string _dataFile;
private string _physicalDataFile;
/// <devdoc>
/// Creates a new instance of AccessDataSource.
/// </devdoc>
public AccessDataSource() : base() {
}
/// <devdoc>
/// Creates a new instance of AccessDataSource with a specified connection string and select command.
/// </devdoc>
public AccessDataSource(string dataFile, string selectCommand) : base() {
if (String.IsNullOrEmpty(dataFile)) {
throw new ArgumentNullException("dataFile");
}
DataFile = dataFile;
SelectCommand = selectCommand;
}
/// <devdoc>
/// Specifies the cache settings for this data source. For the cache to
/// work, the DataSourceMode must be set to DataSet.
/// </devdoc>
internal override DataSourceCache Cache {
get {
if (_cache == null) {
_cache = new FileDataSourceCache();
}
return _cache;
}
}
/// <devdoc>
/// Gets the connection string for the AccessDataSource. This property is auto-generated and cannot be set.
/// </devdoc>
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
]
public override string ConnectionString {
get {
if (_connectionString == null) {
_connectionString = CreateConnectionString();
}
return _connectionString;
}
set {
throw new InvalidOperationException(SR.GetString(SR.AccessDataSource_CannotSetConnectionString));
}
}
/// <devdoc>
/// The name of an Access database file.
/// This property is not stored in ViewState.
/// </devdoc>
[
DefaultValue(""),
Editor("System.Web.UI.Design.MdbDataFileEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)),
UrlProperty(),
WebCategory("Data"),
WebSysDescription(SR.AccessDataSource_DataFile),
]
public string DataFile {
get {
return (_dataFile == null) ? String.Empty : _dataFile;
}
set {
if (DataFile != value) {
_dataFile = value;
_connectionString = null;
_physicalDataFile = null;
RaiseDataSourceChangedEvent(EventArgs.Empty);
}
}
}
/// <devdoc>
/// Gets the file data source cache object.
/// </devdoc>
private FileDataSourceCache FileDataSourceCache {
get {
FileDataSourceCache fileCache = Cache as FileDataSourceCache;
Debug.Assert(fileCache != null, "Cache object should be a FileDataSourceCache");
return fileCache;
}
}
/// <devdoc>
/// Gets the Physical path of the data file.
/// </devdoc>
private string PhysicalDataFile {
get {
if (_physicalDataFile == null) {
_physicalDataFile = GetPhysicalDataFilePath();
}
return _physicalDataFile;
}
}
internal string NativeProvider {
get {
if (IsAccess2007) {
return Access2007Provider;
}
return JetProvider;
}
}
internal virtual bool IsAccess2007 {
get {
// Access 2007 changed the file format so we have to pick the right provider based on extension.
return Path.GetExtension(PhysicalDataFile) == Access2007FileExtension;
}
}
/// <devdoc>
/// Gets/sets the ADO.net managed provider name. This property is restricted to the OLE DB provider and cannot be set.
/// </devdoc>
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
]
public override string ProviderName {
get {
return OleDbProviderName;
}
set {
throw new InvalidOperationException(SR.GetString(SR.AccessDataSource_CannotSetProvider, ID));
}
}
/// <devdoc>
/// A semi-colon delimited string indicating which databases to use for the dependency in the format "database1:table1;database2:table2".
/// </devdoc>
[
Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
]
public override string SqlCacheDependency {
get {
throw new NotSupportedException(SR.GetString(SR.AccessDataSource_SqlCacheDependencyNotSupported, ID));
}
set {
throw new NotSupportedException(SR.GetString(SR.AccessDataSource_SqlCacheDependencyNotSupported, ID));
}
}
private void AddCacheFileDependency() {
FileDataSourceCache.FileDependencies.Clear();
string filename = PhysicalDataFile;
if (filename.Length > 0) {
FileDataSourceCache.FileDependencies.Add(filename);
}
}
/// <devdoc>
/// Creates a connection string for an Access database connection.
/// The JET or ACE provider is used based on the DataFile extension, and the filename, username, password, and
/// share mode are are set.
/// </devdoc>
private string CreateConnectionString() {
return "Provider=" + NativeProvider + "; Data Source=" + PhysicalDataFile;
}
/// <devdoc>
/// Creates a new AccessDataSourceView.
/// </devdoc>
protected override SqlDataSourceView CreateDataSourceView(string viewName) {
return new AccessDataSourceView(this, viewName, Context);
}
protected override DbProviderFactory GetDbProviderFactory() {
return OleDbFactory.Instance;
}
/// <devdoc>
/// Gets the appropriate mapped path for the DataFile.
/// </devdoc>
private string GetPhysicalDataFilePath() {
string filename = DataFile;
if (filename.Length == 0) {
return null;
}
if (!System.Web.Util.UrlPath.IsAbsolutePhysicalPath(filename)) {
// Root relative path
if (DesignMode) {
// This exception should never be thrown - the designer always maps paths
// before using the runtime control.
throw new NotSupportedException(SR.GetString(SR.AccessDataSource_DesignTimeRelativePathsNotSupported, ID));
}
filename = Context.Request.MapPath(filename, AppRelativeTemplateSourceDirectory, true);
}
HttpRuntime.CheckFilePermission(filename, true);
// We also need to check for path discovery permissions for the
// file since the page developer will be able to see the physical
// path in the ConnectionString property.
if (!HttpRuntime.HasPathDiscoveryPermission(filename)) {
throw new HttpException(SR.GetString(SR.AccessDataSource_NoPathDiscoveryPermission, HttpRuntime.GetSafePath(filename), ID));
}
return filename;
}
/// <devdoc>
/// Saves data to the cache.
/// </devdoc>
internal override void SaveDataToCache(int startRowIndex, int maximumRows, object data, CacheDependency dependency) {
AddCacheFileDependency();
base.SaveDataToCache(startRowIndex, maximumRows, data, dependency);
}
/*internal override void SaveTotalRowCountToCache(int totalRowCount) {
AddCacheFileDependency();
base.SaveTotalRowCountToCache(totalRowCount);
}*/
}
}

View File

@ -0,0 +1,45 @@
//------------------------------------------------------------------------------
// <copyright file="AccessDataSourceView.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing.Design;
using System.IO;
using System.Text;
using System.Web.UI;
using System.Web.Util;
public class AccessDataSourceView : SqlDataSourceView {
private AccessDataSource _owner;
/// <devdoc>
/// Creates a new instance of AccessDataSourceView.
/// </devdoc>
public AccessDataSourceView(AccessDataSource owner, string name, HttpContext context) : base(owner, name, context) {
Debug.Assert(owner != null);
_owner = owner;
}
/// <devdoc>
/// Returns all the rows of the datasource.
/// </devdoc>
protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) {
if (String.IsNullOrEmpty(_owner.DataFile)) {
throw new InvalidOperationException(SR.GetString(SR.AccessDataSourceView_SelectRequiresDataFile, _owner.ID));
}
return base.ExecuteSelect(arguments);
}
}
}

View File

@ -0,0 +1,164 @@
//------------------------------------------------------------------------------
// <copyright file="AdCreatedEventArgs.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.Web.Util;
/// <devdoc>
/// <para>Provides data for the <see langword='AdCreated'/> event.</para>
/// </devdoc>
public class AdCreatedEventArgs : EventArgs {
internal const string ImageUrlElement = "ImageUrl";
internal const string NavigateUrlElement = "NavigateUrl";
internal const string AlternateTextElement = "AlternateText";
private const string WidthElement = "Width";
private const string HeightElement = "Height";
private string imageUrl = String.Empty;
private string navigateUrl = String.Empty;
private string alternateText = String.Empty;
private IDictionary adProperties;
private bool hasHeight;
private bool hasWidth;
private Unit width;
private Unit height;
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.Web.UI.WebControls.AdCreatedEventArgs'/>
/// class.</para>
/// </devdoc>
public AdCreatedEventArgs(IDictionary adProperties) :
this(adProperties, null, null, null) {
}
/// <devdoc>
/// <para>Internal constructor for making use of parameter keys if
/// provided. A note is that we cannot change the constructor
/// above because it was made public.</para>
/// </devdoc>
internal AdCreatedEventArgs(IDictionary adProperties,
String imageUrlField,
String navigateUrlField,
String alternateTextField) {
if (adProperties != null) {
// Initialize the other properties from the dictionary
this.adProperties = adProperties;
this.imageUrl = GetAdProperty(ImageUrlElement, imageUrlField);
this.navigateUrl = GetAdProperty(NavigateUrlElement, navigateUrlField);
this.alternateText = GetAdProperty(AlternateTextElement, alternateTextField);
// VSWhidbey 141916: Check validity of Width and Height
hasWidth = GetUnitValue(adProperties, WidthElement, ref width);
hasHeight = GetUnitValue(adProperties, HeightElement, ref height);
}
}
/// <devdoc>
/// <para>Gets the dictionary containing all the advertisement
/// properties extracted from the XML file after the <see langword='AdCreated '/>
/// event is raised.</para>
/// </devdoc>
public IDictionary AdProperties {
get {
return adProperties;
}
}
/// <devdoc>
/// <para>
/// Specifies the alternate text and tooltip (if browser supported) that will be
/// rendered in the <see cref='System.Web.UI.WebControls.AdRotator'/>.</para>
/// </devdoc>
public string AlternateText {
get {
return alternateText;
}
set {
alternateText = value;
}
}
internal bool HasHeight {
get {
return hasHeight;
}
}
internal bool HasWidth {
get {
return hasWidth;
}
}
internal Unit Height {
get {
return height;
}
}
/// <devdoc>
/// <para> Specifies the image that will be rendered in the <see cref='System.Web.UI.WebControls.AdRotator'/>.</para>
/// </devdoc>
public string ImageUrl {
get {
return imageUrl;
}
set {
imageUrl = value;
}
}
/// <devdoc>
/// <para> Specifies the target URL that will be rendered in the
/// <see cref='System.Web.UI.WebControls.AdRotator'/>.</para>
/// </devdoc>
public string NavigateUrl {
get {
return navigateUrl;
}
set {
navigateUrl = value;
}
}
internal Unit Width {
get {
return width;
}
}
private String GetAdProperty(String defaultIndex, String keyIndex) {
String index = (String.IsNullOrEmpty(keyIndex)) ? defaultIndex : keyIndex;
String property = (adProperties == null) ? null : (String) adProperties[index];
return (property == null) ? String.Empty : property;
}
private bool GetUnitValue(IDictionary properties, String keyIndex, ref Unit unitValue) {
Debug.Assert(properties != null);
string temp = properties[keyIndex] as string;
if (!String.IsNullOrEmpty(temp)) {
try {
unitValue = Unit.Parse(temp, CultureInfo.InvariantCulture);
}
catch {
throw new FormatException(
SR.GetString(SR.AdRotator_invalid_integer_format, temp, keyIndex, typeof(Unit).FullName));
}
return true;
}
return false;
}
}
}

View File

@ -0,0 +1,16 @@
//------------------------------------------------------------------------------
// <copyright file="AdCreatedEventHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
/// <devdoc>
/// <para>Represents the method that will handle the
/// <see langword='AdCreated '/> event of an <see cref='System.Web.UI.WebControls.AdRotator'/>.</para>
/// </devdoc>
public delegate void AdCreatedEventHandler(object sender, AdCreatedEventArgs e);
}

View File

@ -0,0 +1,55 @@
//------------------------------------------------------------------------------
// <copyright file="AdPostCacheSubstitution.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* The class is used internally to handle post-cache substitution mechanism in
* AdRotator.
*
* Copyright (c) 2002 Microsoft Corporation
*/
namespace System.Web.UI.WebControls {
using System.Globalization;
using System.IO;
using System.Web.Util;
internal class AdPostCacheSubstitution {
private AdRotator _adRotatorHelper;
private AdPostCacheSubstitution() {}
internal AdPostCacheSubstitution(AdRotator adRotator) {
_adRotatorHelper = new AdRotator();
_adRotatorHelper.CopyFrom(adRotator);
_adRotatorHelper.IsPostCacheAdHelper = true;
_adRotatorHelper.Page = new Page();
}
internal void RegisterPostCacheCallBack(HttpContext context,
Page page,
HtmlTextWriter writer) {
// Assumption: called from AdRotator's Render phase
HttpResponseSubstitutionCallback callback = new HttpResponseSubstitutionCallback(Render);
context.Response.WriteSubstitution(callback);
}
internal string Render(HttpContext context) {
//
Debug.Assert(_adRotatorHelper != null && _adRotatorHelper.Page != null);
// In PostCache Substitution, we use a string writer to return the markup.
StringWriter stringWriter = new StringWriter(CultureInfo.CurrentCulture);
HtmlTextWriter htmlWriter = _adRotatorHelper.Page.CreateHtmlTextWriter(stringWriter);
Debug.Assert(htmlWriter != null);
_adRotatorHelper.RenderControl(htmlWriter);
// Dump the content out as needed for post-cache substitution.
return stringWriter.ToString();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <copyright file="DataBoundControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls.Adapters {
using System.Collections;
public class DataBoundControlAdapter : WebControlAdapter {
protected new DataBoundControl Control {
get {
return (DataBoundControl)base.Control;
}
}
protected internal virtual void PerformDataBinding(IEnumerable data) {
Control.PerformDataBinding(data);
}
}
}

View File

@ -0,0 +1,25 @@
//------------------------------------------------------------------------------
// <copyright file="HideDisabledControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls.Adapters {
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
// Used for controls which use their default rendering, but are hidden when disabled.
public class HideDisabledControlAdapter : WebControlAdapter {
// Returns without doing anything if the control is disabled, otherwise, uses the default rendering.
protected internal override void Render(HtmlTextWriter writer) {
if (Control.Enabled == false) {
return;
}
Control.Render(writer);
}
}
}

View File

@ -0,0 +1,21 @@
//------------------------------------------------------------------------------
// <copyright file="HierarchicalDataBoundControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls.Adapters {
public class HierarchicalDataBoundControlAdapter : WebControlAdapter {
protected new HierarchicalDataBoundControl Control {
get {
return (HierarchicalDataBoundControl)base.Control;
}
}
protected internal virtual void PerformDataBinding() {
Control.PerformDataBinding();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
//------------------------------------------------------------------------------
// <copyright file="WebControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls.Adapters {
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
// Provides adaptive rendering for a web control.
public class WebControlAdapter : ControlAdapter {
// Returns a strongly typed control instance.
protected new WebControl Control {
get {
return (WebControl)base.Control;
}
}
/// Indicates whether the associated WebControl is enabled
/// taking into account the cascading effect of the enabled property.
protected bool IsEnabled {
get {
return Control.IsEnabled;
}
}
protected virtual void RenderBeginTag(HtmlTextWriter writer) {
Control.RenderBeginTag(writer);
}
protected virtual void RenderEndTag(HtmlTextWriter writer) {
Control.RenderEndTag(writer);
}
protected virtual void RenderContents(HtmlTextWriter writer) {
Control.RenderContents(writer);
}
protected internal override void Render(HtmlTextWriter writer) {
RenderBeginTag(writer);
RenderContents(writer);
RenderEndTag(writer);
}
}
}

View File

@ -0,0 +1,55 @@
//------------------------------------------------------------------------------
// <copyright file="WmlListControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
public class WmlAdRotatorAdapter : AdRotatorAdapter {
private bool _firstTimeRender = true;
private bool _wmlTopOfForm;
protected internal override void Render(HtmlTextWriter writer) {
WmlTextWriter wmlWriter = (WmlTextWriter) writer;
if (wmlWriter.AnalyzeMode) {
return;
}
if (Control.DoPostCacheSubstitutionAsNeeded(writer)) {
return;
}
// This is to work around the issue that WmlTextWriter has its
// state info for rendering block level elements, such as <p> tag.
// We keep the state info for subsequent PostCache Render call below.
//
// e.g. If the ad is at the beginning of the form, we need to
// call the method below to explicitly write out a <p> tag for
// a valid WML output.
if (_wmlTopOfForm) {
wmlWriter.BeginRender();
}
if (_firstTimeRender) {
_wmlTopOfForm = wmlWriter.TopOfForm;
_firstTimeRender = false;
}
RenderHyperLinkAsAd(writer);
}
}
}
#endif

View File

@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <copyright file="WmlBaseValidatorAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.WebControls;
public class WmlBaseValidatorAdapter : WmlLabelAdapter {
protected new BaseValidator Control {
get {
return (BaseValidator)base.Control;
}
}
// Renders the control only if the control is evaluated as invalid.
protected internal override void Render(HtmlTextWriter writer) {
if (Control.Enabled &&
!Control.IsValid &&
Control.Display != ValidatorDisplay.None) {
if (Control.Text.Trim().Length == 0 && !Control.HasControls()) {
Control.Text = Control.ErrorMessage;
}
base.Render(writer);
}
}
}
}
#endif

View File

@ -0,0 +1,65 @@
//------------------------------------------------------------------------------
// <copyright file="WmlBulletedListAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Globalization;
using System.Web.UI.WebControls;
using System.Web.Util;
public class WmlBulletedListAdapter : BulletedListAdapter {
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter)markupWriter;
writer.EnterStyle(Control.ControlStyle);
IItemPaginationInfo itemPaginationInfo = (IItemPaginationInfo)Control;
int firstIndex = itemPaginationInfo.FirstVisibleItemIndex;
for (int i = firstIndex; i < firstIndex + itemPaginationInfo.VisibleItemCount; i++) {
RenderBulletText(Control.Items, i, writer);
}
writer.ExitStyle(Control.ControlStyle);
}
// Writes the text of each bullet according to the list's display mode.
protected virtual void RenderBulletText (ListItemCollection items, int index, HtmlTextWriter writer) {
switch (Control.DisplayMode) {
case BulletedListDisplayMode.Text:
writer.WriteEncodedText(items[index].Text);
writer.WriteBreak();
break;
case BulletedListDisplayMode.HyperLink:
//
string targetURL = Control.ResolveClientUrl(items[index].Value);
if (items[index].Enabled) {
PageAdapter.RenderBeginHyperlink(writer, targetURL, true /* encode */, items[index].Text);
writer.Write(items[index].Text);
PageAdapter.RenderEndHyperlink(writer);
} else {
writer.WriteEncodedText(items[index].Text);
}
writer.WriteBreak();
break;
case BulletedListDisplayMode.LinkButton:
if (items[index].Enabled) {
//
PageAdapter.RenderPostBackEvent(writer, Control.UniqueID, index.ToString(CultureInfo.InvariantCulture),
items[index].Text, items[index].Text);
} else {
writer.WriteEncodedText(items[index].Text);
}
writer.WriteBreak();
break;
default:
Debug.Assert(false, "Invalid BulletedListDisplayMode");
break;
}
}
}
}
#endif

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <copyright file="WmlButtonAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.WebControls;
public class WmlButtonAdapter : ButtonAdapter {
protected internal override void Render(HtmlTextWriter writer) {
RenderAsPostBackLink(writer);
}
// renders the button as a postback link
protected override void RenderAsPostBackLink(HtmlTextWriter writer) {
String text = Control.Text;
String softkeyLabel = Control.SoftkeyLabel;
string postUrl = Control.PostBackUrl;
if (!String.IsNullOrEmpty(postUrl)) {
postUrl = ((WebControl)Control).ResolveClientUrl(Control.PostBackUrl);
}
writer.EnterStyle(((WebControl)Control).ControlStyle);
// Do not encode LinkButton Text for V1 compatibility.
if (!(Control is LinkButton) ){
text = text.Replace("$", "$$");
text = HttpUtility.HtmlEncode(text);
softkeyLabel = softkeyLabel.Replace("$", "$$");
softkeyLabel = HttpUtility.HtmlEncode(softkeyLabel);
}
PageAdapter.RenderPostBackEvent(writer, ((Control)base.Control).UniqueID, null /* argument */, softkeyLabel, text, postUrl, null /* accesskey */);
writer.ExitStyle(((WebControl)Control).ControlStyle);
}
}
}
#endif

View File

@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <copyright file="WmlChangePasswordAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
public class WmlChangePasswordAdapter : ChangePasswordAdapter {
// Overridden to render the validator *before* the label, to ensure the validator
// is presented on the correct screen.
protected override void RenderInput(HtmlTextWriter writer, Literal label, Control textBox, Control validator) {
validator.RenderControl(writer);
// In the ChangePassword control, many styles are applied to the table cell that contains
// a child control, rather than the child control itself. We must apply the proper
// style from the ChangePassword control to any control we create for adaptive rendering.
// VSWhidbey 81240
Label newLabel = new Label();
newLabel.Text = label.Text;
newLabel.Page = Page;
newLabel.ApplyStyle(Control.LabelStyle);
newLabel.RenderControl(writer);
// TextBoxStyle is applied directly to the TextBox in the ChangePassword control
textBox.RenderControl(writer);
}
}
}
#endif

View File

@ -0,0 +1,108 @@
//------------------------------------------------------------------------------
// <copyright file="WmlCheckBoxAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
using System.Web.Util;
public class WmlCheckBoxAdapter : CheckBoxAdapter, IPostBackDataHandler {
private const String _clientPrefix = "__cb_";
private string _ivalue = null;
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter) markupWriter;
// If control is not enabled, don't render it at
// all for WML.
if (!Control.Enabled) {
RenderDisabled(writer);
return;
}
((WmlPageAdapter)PageAdapter).RegisterPostField(writer, Control);
// determine if control is already checked.
// if so, set initial value.
_ivalue = Control.Checked ? "1" : String.Empty;
((WmlPageAdapter)PageAdapter).AddFormVariable (writer, Control.ClientID, _ivalue, false /* randomID */);
// does not render __ivalue if null or form variables written.
writer.WriteBeginSelect(null, null, Control.ClientID, _ivalue, Control.ToolTip, true /* multiselect*/);
if (Control.AutoPostBack) {
((WmlPageAdapter)PageAdapter).RenderSelectOptionAsAutoPostBack(writer, Control.Text, null);
}
else {
((WmlPageAdapter)PageAdapter).RenderSelectOption(writer, Control.Text);
}
writer.WriteEndSelect();
}
/// <internalonly/>
// Parse the WML posted data appropriately.
bool IPostBackDataHandler.LoadPostData(String key, NameValueCollection data) {
return LoadPostData(key, data);
}
/// <internalonly/>
// Parse the WML posted data appropriately.
protected virtual bool LoadPostData(String key, NameValueCollection data) {
bool dataChanged = false;
String[] selectedItems = data.GetValues(key);
if (String.IsNullOrEmpty(selectedItems)) {
// This shouldn't happen if we're posting back from the form that
// contains the checkbox. It could happen when being called
// as the result of a postback from another form on the page,
// so we just return quietly.
return false;
}
// For a checkbox, our selection list
// has only one item.
Debug.Assert(selectedItems.Length == 1, "Checkbox selection " +
"list has more than one value");
string selectedItem = selectedItems[0];
if (selectedItem != null && selectedItem.Length == 0) {
dataChanged = Control.Checked == true;
Control.Checked = false;
}
else if (StringUtil.EqualsIgnoreCase(selectedItem, "1")) {
dataChanged = Control.Checked == false;
Control.Checked = true;
}
return dataChanged;
}
/// <internalonly/>
// Raises the post data changed event.
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
/// <internalonly/>
// Raises the post data changed event.
protected virtual void RaisePostDataChangedEvent() {
((IPostBackDataHandler)Control).RaisePostDataChangedEvent();
}
}
}
#endif

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <copyright file="WmlLiteralControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.Adapters {
using System;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
public class WmlDataBoundLiteralControlAdapter : DataBoundLiteralControlAdapter {
protected internal override void BeginRender(HtmlTextWriter writer) {
}
protected internal override void EndRender(HtmlTextWriter writer) {
}
//
protected internal override void Render(HtmlTextWriter writer) {
WmlTextWriter wmlWriter = writer as WmlTextWriter;
if (wmlWriter == null) {
// MMIT legacy case (else pageAdapter would have generated a WmlTextWriter).
Control.Render(writer);
return;
}
Render(wmlWriter);
}
public virtual void Render(WmlTextWriter writer) {
((WmlPageAdapter)PageAdapter).RenderTransformedText(writer, Control.Text);
}
}
}
#endif

View File

@ -0,0 +1,27 @@
//------------------------------------------------------------------------------
// <copyright file="WmlFileUploadAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;
public class WmlFileUploadAdapter : FileUploadAdapter {
protected internal override void Render(HtmlTextWriter writer) {
String alternateText = Control.AlternateText;
if (!String.IsNullOrEmpty(alternateText)) {
writer.EnterStyle(Control.ControlStyle);
writer.Write(LiteralControlAdapterUtility.ProcessWmlLiteralText(alternateText));
writer.ExitStyle(Control.ControlStyle);
}
}
}
}
#endif

View File

@ -0,0 +1,28 @@
//------------------------------------------------------------------------------
// <copyright file="WmlHiddenFieldAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;
public class WmlHiddenFieldAdapter : HiddenFieldAdapter {
protected internal override void BeginRender(HtmlTextWriter writer) {
}
protected internal override void EndRender(HtmlTextWriter writer) {
}
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter)markupWriter;
((WmlPageAdapter)PageAdapter).RegisterPostField(writer, Control.UniqueID, Control.Value, false, false);
}
}
}
#endif

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