- zetalibnet-src.zip
- Core
- Base
- bin
- Release
- de
- ZetaLib.Core.resources.dll
- ICSharpCode.SharpZipLib.dll
- Interop.ADODB.dll
- Interop.JRO.dll
- log4net.dll
- ZetaLib.Core.dll
- Caching
- Collections
- Common
- Core.csproj
- Core.csproj.user
- Core.csproj.vspscc
- Data
- DirectoryServices
- IO
- LibraryConfiguration.cs
- Localization
- Logging
- Misc
- mssccprj.scc
- Properties
- vssver2.scc
- zetalib.core.snk
- mssccprj.scc
- References
- ClickOnceButton
- bin
- ClickOnceButton.dll
- src
- log4net
- log4net.dll
- SharpZip.NET
- Test
- vssver2.scc
- Web
- Base
- bin
- Release
- ClickOnceButton.dll
- de
- ZetaLib.Core.resources.dll
- ZetaLib.Web.resources.dll
- ICSharpCode.SharpZipLib.dll
- Interop.ADODB.dll
- Interop.JRO.dll
- log4net.dll
- ZetaLib.Core.dll
- ZetaLib.Web.dll
- Caching
- Common
- Controls
- LibraryConfiguration.cs
- mssccprj.scc
- Properties
- vssver2.scc
- Web.csproj
- Web.csproj.user
- Web.csproj.vspscc
- zetalib.web.snk
- Windows
- Base
- bin
- Release
- de
- ZetaLib.Core.resources.dll
- ZetaLib.Windows.resources.dll
- ICSharpCode.SharpZipLib.dll
- Interop.ADODB.dll
- Interop.JRO.dll
- log4net.dll
- ZetaLib.Core.dll
- ZetaLib.Windows.dll
- Common
- Controls
- Dialogs
- LibraryConfiguration.cs
- Misc
- mssccprj.scc
- Properties
- vssver2.scc
- Windows.csproj
- Windows.csproj.user
- Windows.csproj.vspscc
- zetalib.windows.snk
- ZetaLibNet.sln
- ZetaLibNet.vssscc
|
namespace ZetaLib.Web.Base
{
#region Using directives.
// ----------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Web.UI;
using ZetaLib.Web.Common;
using ZetaLib.Core.Logging;
using ZetaLib.Web.Properties;
using System.Web.UI.HtmlControls;
using ZetaLib.Web.Controls;
// ----------------------------------------------------------------------
#endregion
/////////////////////////////////////////////////////////////////////////
/// <summary>
/// Base class for user controls.
/// </summary>
public class UserControlBase :
UserControl
{
#region Testing whether JavaScript is enabled.
// ------------------------------------------------------------------
/// <summary>
/// Set to true to enable checking whether JavaScript is enabled.
/// Does a postback if turned on.
/// </summary>
/// <value>
/// <c>true</c> if [want test java script enabled]; otherwise, <c>false</c>.
/// </value>
protected bool WantTestJavaScriptEnabled
{
get
{
return wantTestJavaScriptEnabled;
}
set
{
wantTestJavaScriptEnabled = value;
if ( value )
{
javaScriptTester = new JavascriptTest();
this.Controls.Add( javaScriptTester );
}
else
{
if ( javaScriptTester != null )
{
this.Controls.Remove( javaScriptTester );
javaScriptTester = null;
}
}
}
}
private bool wantTestJavaScriptEnabled = false;
/// <summary>
/// Checks whether JavaScript is enabled on the client.
/// </summary>
/// <value>
/// <c>true</c> if this instance is java script enabled; otherwise, <c>false</c>.
/// </value>
protected bool IsJavaScriptEnabled
{
get
{
object o = Session[@"IsJavaScriptEnabled"];
if ( o == null )
{
if ( !wantTestJavaScriptEnabled )
{
throw new ArgumentException(
string.Format(
Resources.Str_ZetaLib_Web_Base_UserControlBase_01 ) );
}
else
{
bool b = javaScriptTester.Enabled;
if ( IsPostBack )
{
Session[@"IsJavaScriptEnabled"] = b;
}
return b;
}
}
else
{
bool b = Convert.ToBoolean( o );
return b;
}
}
}
private JavascriptTest javaScriptTester = null;
// ------------------------------------------------------------------
#endregion
#region Overrides.
// ------------------------------------------------------------------
/// <summary>
/// Raises the <see cref="E:System.Web.UI.Control.Load"></see> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
protected override void OnLoad(
EventArgs e )
{
base.OnLoad( e );
if ( (Page is PageBase) &&
((PageBase)Page).AutoDataBind )
{
LogCentral.Current.LogDebug(
@"Databinding in ZetaLib.Web.Base.UserControlBase.OnLoad(), " +
@"because ZetaLib.Web.Base.PageBase.AutoDataBind is true." );
DataBind();
}
}
/// <summary>
/// Handles the pressing of the [enter] key on a textbox,
/// to automatically submit the form.
/// </summary>
/// <param name="button">The button.</param>
/// <returns></returns>
/// <remarks>
/// To use this function, simply add the following attribute to
/// a textbox inside the .ASPX file:
/// OnKeyDown='GlobalKeyDownEnterHandler(CmdSubmit)'
/// Where "CmdSubmit" is the ID of the button to press upon [enter].
/// </remarks>
protected string GlobalKeyDownEnterHandler(
Control button )
{
return string.Format(
@"GlobalKeyDownEnterHandler( {0} )",
button.ClientID );
}
// ------------------------------------------------------------------
#endregion
#region Public properties.
// ------------------------------------------------------------------
/// <summary>
/// Provides access to an enhanced version of the query string parameters.
/// </summary>
/// <value>The QS.</value>
public QueryString QS
{
get
{
// I must not create a separate instance but must
// use the same QS object as the page.
if ( Page != null && Page is PageBase )
{
return ((PageBase)Page).QS;
}
else
{
return null;
}
}
}
/// <summary>
/// Access an instance of the web cache.
/// </summary>
/// <value>The page cache.</value>
public System.Web.Caching.Cache PageCache
{
get
{
if ( Page != null && Page is PageBase )
{
return ((PageBase)Page).PageCache;
}
else
{
return null;
}
}
}
/// <summary>
/// Provides access to the resource manager, that enables to load
/// multilingual strings from the database.
/// </summary>
/// <value>The res man.</value>
public DBStringResourceManagerBase ResMan
{
get
{
Debug.Assert(
Page != null && Page is PageBase,
@"Page is either NULL or not derived from PageBase." );
return ((PageBase)Page).ResMan;
}
}
/// <summary>
/// Get/set the text that appears as an error text on the page.
/// </summary>
/// <value>The error text.</value>
public virtual string ErrorText
{
get
{
return ErrorTextControl.InnerHtml;
}
set
{
string s = value;
ErrorTextControl.InnerHtml = s;
ErrorTextControl.Visible =
ErrorTextControl.InnerHtml.Length > 0;
}
}
/// <summary>
/// Tries to locate a control with the ID 'ErrorTextControl' on
/// the current page.
/// </summary>
/// <value>The error text control.</value>
public virtual HtmlGenericControl ErrorTextControl
{
get
{
return (Page as PageBase).ErrorTextControl;
}
}
// ------------------------------------------------------------------
#endregion
}
/////////////////////////////////////////////////////////////////////////
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.