C# Class EnterpriseWebLibrary.NetTools

Contains methods that are useful to web applications.
Exibir arquivo Open project: enduracode/enterprise-web-library Class Usage Examples

Public Methods

Method Description
AddJavaScriptEventScript ( this control, string jsEventConstant, string script ) : void

Adds the specified JavaScript to the specified event handler of the specified control. Do not pass null for script. Use JsWritingMethods constants for events. To add an onsubmit event, use ClientScript.RegisterOnSubmitStatement instead. A semicolon will be added to the end of the script.

BuildBasicLink ( string text, string url, bool navigatesInNewWindow ) : string

Returns an anchor tag with the specified parameters. Use this only for status messages that are being built after LoadData. In all other cases, use EwfLink.

CombineUrls ( string one, string two ) : string

Combines the given URLs into a single URL with no trailing slash.

CreateImageFromText ( string text, Font font ) : EwfResponse

Creates an image with the given text and font and returns a response object. Text will be all on one line and will not be wider than 800 pixels or higher than 150 pixels. Do not pass null for text. Passing null for font will result in a generic Sans Serif, 10pt font.

GetCookie ( string name ) : System.Web.HttpCookie
GetRelativeUrlToAscxFromType ( Type type ) : string

Given a type, generates a Url based on the namespace and type. Every level of the namespace up to and including the first one that ends in with the string "site" (case insensitive) is dropped. The type "MyControl" in namespace "one.two.three.MyWebSite.Stuff.MyControls" will return "Stuff/MyControls/MyControl.ascx".

GetTextAsEncodedHtml ( this text, bool returnNonBreakingSpaceIfEmpty = true ) : string

Encodes the given text as HTML, replacing instances of \n with <br/> and optionally replacing the empty string with a non-breaking space.

LinkIsBroken ( string url ) : bool

Gets whether a request for the specified URL returns an HTTP status code other than 200 OK.

Redirect ( string url ) : void

Redirects to the given URL. Throws a ThreadAbortedException. NOTE: Make this internal.

SetInitialDisplay ( this control, bool visible ) : void

Sets the initial visibility of a web control. This can be used in tandem with DisplayLinking.

Private Methods

Method Description
ExecuteWithResponse ( string url, Action method, bool disableCertificateValidation = false ) : void
IsWebApp ( ) : bool
ToggleInitialDisplay ( this control ) : void

Sets the initial visibility of the given control to the opposite of what it currently is.

getResponseForAnyStatusCode ( this request ) : HttpWebResponse

Gets a response and prevents exceptions caused by HTTP status codes. From http://stackoverflow.com/a/1366869/35349.

getResponseIfPossible ( this request ) : HttpWebResponse

Method Details

AddJavaScriptEventScript() public static method

Adds the specified JavaScript to the specified event handler of the specified control. Do not pass null for script. Use JsWritingMethods constants for events. To add an onsubmit event, use ClientScript.RegisterOnSubmitStatement instead. A semicolon will be added to the end of the script.
public static AddJavaScriptEventScript ( this control, string jsEventConstant, string script ) : void
control this
jsEventConstant string
script string
return void

BuildBasicLink() public static method

Returns an anchor tag with the specified parameters. Use this only for status messages that are being built after LoadData. In all other cases, use EwfLink.
public static BuildBasicLink ( string text, string url, bool navigatesInNewWindow ) : string
text string
url string
navigatesInNewWindow bool
return string

CombineUrls() public static method

Combines the given URLs into a single URL with no trailing slash.
public static CombineUrls ( string one, string two ) : string
one string A URL, not null.
two string A URL, not null.
return string

CreateImageFromText() public static method

Creates an image with the given text and font and returns a response object. Text will be all on one line and will not be wider than 800 pixels or higher than 150 pixels. Do not pass null for text. Passing null for font will result in a generic Sans Serif, 10pt font.
public static CreateImageFromText ( string text, Font font ) : EwfResponse
text string
font System.Drawing.Font
return EnterpriseWebLibrary.EnterpriseWebFramework.EwfResponse

GetCookie() public static method

public static GetCookie ( string name ) : System.Web.HttpCookie
name string
return System.Web.HttpCookie

GetRelativeUrlToAscxFromType() public static method

Given a type, generates a Url based on the namespace and type. Every level of the namespace up to and including the first one that ends in with the string "site" (case insensitive) is dropped. The type "MyControl" in namespace "one.two.three.MyWebSite.Stuff.MyControls" will return "Stuff/MyControls/MyControl.ascx".
public static GetRelativeUrlToAscxFromType ( Type type ) : string
type System.Type
return string

GetTextAsEncodedHtml() public static method

Encodes the given text as HTML, replacing instances of \n with <br/> and optionally replacing the empty string with a non-breaking space.
public static GetTextAsEncodedHtml ( this text, bool returnNonBreakingSpaceIfEmpty = true ) : string
text this
returnNonBreakingSpaceIfEmpty bool
return string

LinkIsBroken() public static method

Gets whether a request for the specified URL returns an HTTP status code other than 200 OK.
public static LinkIsBroken ( string url ) : bool
url string
return bool

Redirect() public static method

Redirects to the given URL. Throws a ThreadAbortedException. NOTE: Make this internal.
public static Redirect ( string url ) : void
url string
return void

SetInitialDisplay() public static method

Sets the initial visibility of a web control. This can be used in tandem with DisplayLinking.
public static SetInitialDisplay ( this control, bool visible ) : void
control this
visible bool
return void