System.Web.UI Namespace Control Class
Resolves a relative URL to an absolute URL based on the value passed to the TemplateSourceDirectory property.
[ VB ]
Public Function ResolveUrl ( _
ByVal relativeUrl As String _
) As String
[ C# ]
public string ResolveUrl (
string relativeUrl
);
[ C++ ]
public: String* ResolveUrl (
String* relativeUrl
);
[ JScript ]
public function ResolveUrl (
relativeUrl : String
) : String;
- relativeUrl
- The relative URL associated with the TemplateSourceDirectory property.
The absolute URL.
Exception Type |
Condition |
ArgumentException |
Thrown if the relativeUrl parameter is a null reference
( Nothing in Visual Basic ). |
This method uses the TemplateSourceDirectory property to resolve to the absolute URL. The returned URL is for client use, and contains the session cookie if appropriate.
The following example demonstrates using the ResolveUrl method.
public class myResolveUrl:Control {
private string _ImageUrl;
public string ImageUrl {
get {
return _ImageUrl;
}
set {
_ImageUrl = value;
}
}
protected override void Render ( HtmlTextWriter output ) {
Image myImage = new Image ( );
// Resolve Url.
myImage.ImageUrl = ResolveUrl ( this.ImageUrl );
myImage.RenderControl ( output );
}
}
Public Class myResolveUrl Inherits Control
Private _ImageUrl As String
Public Property ImageUrl ( ) As String
Get
Return _ImageUrl
End Get
Set
_ImageUrl = value
End Set
End Property
Protected Overrides Sub Render ( output As HtmlTextWriter )
Dim myImage As New Image ( )
' Resolve Url.
myImage.ImageUrl = ResolveUrl ( Me.ImageUrl )
myImage.RenderControl ( output )
End Sub
End Class |
|
C# |
VB |
Control Members