Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / ErrorFormatterPage.cs / 1305376 / ErrorFormatterPage.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.Mobile;
using System.Security.Permissions;
namespace System.Web.UI.MobileControls
{
/*
* Error Formatter page class.
* This is essentially a precompiled Mobile page, that formats error messages
* for other devices.
*
* NOTE: While there is nothing in the framework to let the developer override
* this page, it has been written so the developer can do so.
*
* Copyright (c) 2000 Microsoft Corporation
*/
///
[
ToolboxItem(false)
]
[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 ErrorFormatterPage : MobilePage
{
private MobileErrorInfo _errorInfo;
///
protected MobileErrorInfo ErrorInfo
{
get
{
return _errorInfo;
}
}
///
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
EnableViewState = false;
_errorInfo = Context.Items[MobileErrorInfo.ContextKey] as MobileErrorInfo;
if (_errorInfo == null)
{
// Don't care what kind of exception, since it'll be handled
// quietly by the error handler module.
throw new Exception ();
}
InitContent ();
}
private MobileControl CreateControlForText(String text)
{
if (text.IndexOf('\r') != -1)
{
TextView textView = new TextView();
textView.Text = text;
return textView;
}
else
{
Label label = new Label();
label.Text = text;
return label;
}
}
///
protected virtual void InitContent()
{
Form form;
MobileControl ctl;
// Error form.
form = new Form();
form.Title = SR.GetString(SR.ErrorFormatterPage_ServerError,
HttpRuntime.AppDomainAppVirtualPath);
form.Wrapping = Wrapping.Wrap;
IParserAccessor formAdd = (IParserAccessor)form;
// Error title.
ctl = CreateControlForText(ErrorInfo.Type);
ctl.StyleReference = Constants.ErrorStyle;
ctl.Font.Size = FontSize.Large;
ctl.Font.Bold = BooleanOption.True;
formAdd.AddParsedSubObject(ctl);
// Error description.
ctl = CreateControlForText(ErrorInfo.Description);
formAdd.AddParsedSubObject(ctl);
// Error miscellaneous text, if there is any.
if (ErrorInfo.MiscTitle.Length > 0)
{
ctl = CreateControlForText(SR.GetString(SR.ErrorFormatterPage_MiscErrorMessage,
ErrorInfo.MiscTitle,
ErrorInfo.MiscText));
formAdd.AddParsedSubObject(ctl);
}
// File/Line number info, if any.
if (ErrorInfo.File.Length > 0)
{
Label label;
label = new Label();
label.Text = SR.GetString(SR.ErrorFormatterPage_File, ErrorInfo.File);
formAdd.AddParsedSubObject(label);
label = new Label();
label.Text = SR.GetString(SR.ErrorFormatterPage_Line, ErrorInfo.LineNumber);
formAdd.AddParsedSubObject(label);
}
Controls.Add(form);
}
///
protected override void SavePageStateToPersistenceMedium(Object viewState)
{
// Override and ignore. No need to save view state for this page.
}
///
protected override Object LoadPageStateFromPersistenceMedium()
{
// Override and ignore. No view state to load for this page.
return null;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.Mobile;
using System.Security.Permissions;
namespace System.Web.UI.MobileControls
{
/*
* Error Formatter page class.
* This is essentially a precompiled Mobile page, that formats error messages
* for other devices.
*
* NOTE: While there is nothing in the framework to let the developer override
* this page, it has been written so the developer can do so.
*
* Copyright (c) 2000 Microsoft Corporation
*/
///
[
ToolboxItem(false)
]
[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 ErrorFormatterPage : MobilePage
{
private MobileErrorInfo _errorInfo;
///
protected MobileErrorInfo ErrorInfo
{
get
{
return _errorInfo;
}
}
///
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
EnableViewState = false;
_errorInfo = Context.Items[MobileErrorInfo.ContextKey] as MobileErrorInfo;
if (_errorInfo == null)
{
// Don't care what kind of exception, since it'll be handled
// quietly by the error handler module.
throw new Exception ();
}
InitContent ();
}
private MobileControl CreateControlForText(String text)
{
if (text.IndexOf('\r') != -1)
{
TextView textView = new TextView();
textView.Text = text;
return textView;
}
else
{
Label label = new Label();
label.Text = text;
return label;
}
}
///
protected virtual void InitContent()
{
Form form;
MobileControl ctl;
// Error form.
form = new Form();
form.Title = SR.GetString(SR.ErrorFormatterPage_ServerError,
HttpRuntime.AppDomainAppVirtualPath);
form.Wrapping = Wrapping.Wrap;
IParserAccessor formAdd = (IParserAccessor)form;
// Error title.
ctl = CreateControlForText(ErrorInfo.Type);
ctl.StyleReference = Constants.ErrorStyle;
ctl.Font.Size = FontSize.Large;
ctl.Font.Bold = BooleanOption.True;
formAdd.AddParsedSubObject(ctl);
// Error description.
ctl = CreateControlForText(ErrorInfo.Description);
formAdd.AddParsedSubObject(ctl);
// Error miscellaneous text, if there is any.
if (ErrorInfo.MiscTitle.Length > 0)
{
ctl = CreateControlForText(SR.GetString(SR.ErrorFormatterPage_MiscErrorMessage,
ErrorInfo.MiscTitle,
ErrorInfo.MiscText));
formAdd.AddParsedSubObject(ctl);
}
// File/Line number info, if any.
if (ErrorInfo.File.Length > 0)
{
Label label;
label = new Label();
label.Text = SR.GetString(SR.ErrorFormatterPage_File, ErrorInfo.File);
formAdd.AddParsedSubObject(label);
label = new Label();
label.Text = SR.GetString(SR.ErrorFormatterPage_Line, ErrorInfo.LineNumber);
formAdd.AddParsedSubObject(label);
}
Controls.Add(form);
}
///
protected override void SavePageStateToPersistenceMedium(Object viewState)
{
// Override and ignore. No need to save view state for this page.
}
///
protected override Object LoadPageStateFromPersistenceMedium()
{
// Override and ignore. No view state to load for this page.
return null;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IOThreadTimer.cs
- DataGridSortingEventArgs.cs
- ClientSideQueueItem.cs
- KnownTypesHelper.cs
- StylusPoint.cs
- DynamicDocumentPaginator.cs
- Panel.cs
- RowBinding.cs
- DataGridViewCellValidatingEventArgs.cs
- ObjectDataSourceMethodEventArgs.cs
- DocumentScope.cs
- ListViewGroup.cs
- UdpSocketReceiveManager.cs
- RadialGradientBrush.cs
- UpWmlMobileTextWriter.cs
- HierarchicalDataBoundControl.cs
- Parameter.cs
- LogRecordSequence.cs
- User.cs
- CounterCreationData.cs
- Transform3D.cs
- EventArgs.cs
- GridEntryCollection.cs
- HatchBrush.cs
- MimeParameterWriter.cs
- NativeMethods.cs
- ListenerConnectionDemuxer.cs
- ProfilePropertySettingsCollection.cs
- XmlSubtreeReader.cs
- HtmlTableCell.cs
- XsdBuildProvider.cs
- CellTreeNodeVisitors.cs
- DbgUtil.cs
- XmlTypeAttribute.cs
- ObjectDataSource.cs
- ConnectionManager.cs
- XmlSerializer.cs
- WebResourceAttribute.cs
- ISAPIApplicationHost.cs
- ParamArrayAttribute.cs
- AutomationPeer.cs
- BindingEntityInfo.cs
- IImplicitResourceProvider.cs
- SQLChars.cs
- WebUtil.cs
- WebErrorHandler.cs
- sqlinternaltransaction.cs
- KeySpline.cs
- ListViewInsertionMark.cs
- TypeConverterValueSerializer.cs
- Rect.cs
- StorageComplexPropertyMapping.cs
- DefaultValueConverter.cs
- FontStretches.cs
- ControlParameter.cs
- WebPartRestoreVerb.cs
- FlowSwitchLink.cs
- MetadataSerializer.cs
- WorkerRequest.cs
- HMACMD5.cs
- DetailsView.cs
- PolyQuadraticBezierSegment.cs
- AuthenticationModuleElementCollection.cs
- XmlSchemaElement.cs
- ACE.cs
- wmiprovider.cs
- ChangeConflicts.cs
- SelectionItemProviderWrapper.cs
- BitmapEffectDrawingContextWalker.cs
- FileLoadException.cs
- PathSegment.cs
- CodeDirectionExpression.cs
- StreamGeometry.cs
- DbProviderFactories.cs
- SystemWebSectionGroup.cs
- PriorityQueue.cs
- InputScopeConverter.cs
- TypeDescriptor.cs
- ExecutedRoutedEventArgs.cs
- OrderByLifter.cs
- ClientCredentialsElement.cs
- PictureBox.cs
- XhtmlTextWriter.cs
- EditorZone.cs
- ObjectItemConventionAssemblyLoader.cs
- DbMetaDataCollectionNames.cs
- QuaternionValueSerializer.cs
- SoapReflector.cs
- BackStopAuthenticationModule.cs
- ProcessHostConfigUtils.cs
- Util.cs
- ViewGenResults.cs
- altserialization.cs
- OracleTransaction.cs
- DeferredSelectedIndexReference.cs
- SessionStateContainer.cs
- XmlRootAttribute.cs
- EntityObject.cs
- StorageScalarPropertyMapping.cs
- XXXOnTypeBuilderInstantiation.cs