Class WebUtils

Summary description for wwWebUtils.

System.Object
  Westwind.Utilities.WebUtils
public static class WebUtils : object

Class Members

MemberDescription

AspTextMerge

Returns the result from an ASPX 'template' page in the /templates directory of this application. This method uses an HTTP client to call into the Web server and retrieve the result as a string.

public static string AspTextMerge(string templatePageAndQueryString,     ref string errorMessage)

CssLink

Inserts a CSS tag into the page. Includes carriage return at end.

public static string CssLink(string url)

DecodeJsString

Parses a JSON string into a string value

public static string DecodeJsString(string encodedString)

EncodeJsDate

Converts a .NET date to a JavaScript JSON date value.

public static string EncodeJsDate(DateTime date,     JsonDateEncodingModes dateMode)

EncodeJsString

Encodes a string to be represented as a string literal. The format is essentially a JSON string that is returned in double quotes.

public static string EncodeJsString(string s)

FindControlRecursive

Finds a Control recursively. Note finds the first match and exits

public static Control FindControlRecursive(Control Root,     string id,     bool alwaysUseFindControl)

ForceReload

Creates the headers required to force the current request to not go into the client side cache, forcing a reload of the page.

public static void ForceReload()

FormBufferToString

Returns the content of the POST buffer as string

public static string FormBufferToString()

FormVarsToDataRow

public static bool FormVarsToDataRow(DataRow dataRow,     string formvarPrefixes,     Dictionary<String,String> errors)

FormVarsToObject

public static bool FormVarsToObject(object target,     string formvarPrefixes,     Dictionary<String,String> errors)

GetAppRelativePath

Translates an ASP.NET path like /myapp/subdir/page.aspx into an application relative path: subdir/page.aspx. The path returned is based of the application base and starts either with a subdirectory or page name (ie. no ~)

public static string GetAppRelativePath(string logicalPath)

public static string GetAppRelativePath()

GetControlAppRelativePath

Returns the executing ASPX, ASCX, MASTER page for a control instance. Path is returned app relative without a leading slash

public static string GetControlAppRelativePath(Control Ctl)

GetFullApplicationPath

Returns the Application Path as a full Url with scheme

public static string GetFullApplicationPath()

GetParamsInt

Returns a request value parsed into an integer. If the value is not found or not a number null is returned.

public static int? GetParamsInt(string paramsKey)

public static int GetParamsInt(string paramsKey,     int defaultValue)

GetUrlEncodedKey

Retrieves a value by key from a UrlEncoded string.

public static string GetUrlEncodedKey(string urlEncodedString,     string key)

GetUrlPath

Returns just the Path of a full Url. Strips off the filename and querystring

public static string GetUrlPath(string url)

GRes

Returns a resource string. Shortcut for HttpContext.GetGlobalResourceObject.

public static string GRes(string resourceSet,     string resourceId)

public static string GRes(string resourceId)

GResJs

Returns a JavaScript Encoded string from a Global Resource

public static string GResJs(string classKey,     string resourceId)

public static string GResJs(string resourceKey)

GZipEncodePage

Sets up the current page or handler to use GZip through a Response.Filter IMPORTANT: You have to call this method before any output is generated!

public static void GZipEncodePage()

ImageFormatFromContentType

Returns an image format from an HTTP content type string

public static ImageFormat ImageFormatFromContentType(string contentType)

ImageFormatToContentType

Converts an ImageFormat value to a Web Content Type

public static string ImageFormatToContentType(ImageFormat format)

IsFormVar

Checks to see if a form variable exists in the HttpContext. Only works in System.Web based applications

public static bool IsFormVar(string key)

IsGZipSupported

Determines if GZip is supported

public static bool IsGZipSupported()

LRes

Returns a local resource from the resource set of the current active request local resource.

public static string LRes(string resourceId)

public static string LRes(string resourceSet,     string resourceKey)

LResJs

Returns a local resource properly encoded as a JavaScript string including the quote characters.

public static string LResJs(string resourceId)

MachineKeySeedValue

Returns an encrypted string based on the local machine key of the local machine. Can be used to create machine specific seed values that cannot be tracked via code

public static string MachineKeySeedValue(Byte[] keyData)

RenderControl

Renders a control to a string - useful for AJAX return values

public static string RenderControl(Control control)

public static string RenderControl(Control control,     bool useDynamicPage)

RenderUserControl

Renders a user control into a string into a string.

public static string RenderUserControl(string userControlVirtualPath,     bool includePostbackControls,     object data)

public static string RenderUserControl(string userControlVirtualPath,     bool includePostbackControls)

ResolveServerUrl

This method returns a fully qualified absolute server Url which includes the protocol, server, port in addition to the server relative Url.

public static string ResolveServerUrl(string serverUrl,     bool forceHttps)

public static string ResolveServerUrl(string serverUrl)

ResolveUrl

Returns a site relative HTTP path from a partial path starting out with a ~. Same syntax that ASP.Net internally supports but this method can be used outside of the Page framework.

public static string ResolveUrl(string originalUrl)

RestartWebApplication

Attempts to restart the active Web Application

public static bool RestartWebApplication()

ScriptLink

Inserts a