Class WebUtils

Summary description for wwWebUtils.

public static class WebUtils : object

Class Members



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)


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

public static string CssLink(string url)


Parses a JSON string into a string value

public static string DecodeJsString(string encodedString)


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

public static string EncodeJsDate(DateTime date,     JsonDateEncodingModes dateMode)


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)


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

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


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()


Returns the content of the POST buffer as string

public static string FormBufferToString()


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


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


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()


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)


Returns the Application Path as a full Url with scheme

public static string GetFullApplicationPath()


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)


Retrieves a value by key from a UrlEncoded string.

public static string GetUrlEncodedKey(string urlEncodedString,     string key)


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

public static string GetUrlPath(string url)


Returns a resource string. Shortcut for HttpContext.GetGlobalResourceObject.

public static string GRes(string resourceSet,     string resourceId)

public static string GRes(string resourceId)


Returns a JavaScript Encoded string from a Global Resource

public static string GResJs(string classKey,     string resourceId)

public static string GResJs(string resourceKey)


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()


Returns an image format from an HTTP content type string

public static ImageFormat ImageFormatFromContentType(string contentType)


Converts an ImageFormat value to a Web Content Type

public static string ImageFormatToContentType(ImageFormat format)


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

public static bool IsFormVar(string key)


Determines if GZip is supported

public static bool IsGZipSupported()


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)


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

public static string LResJs(string resourceId)


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)


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)


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)


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)


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)


Attempts to restart the active Web Application

public static bool RestartWebApplication()


Inserts a