- Name Location
- CSS Class NA
- Type NA
The Location object represents a middle ground between Javascript's
window.location and .Net's URI class. Various controls use a Location
object to build their paths, for example the Form's action attribute.
The Chan.Page base class has a built in Location object that represents
that page, it is this that child controls key off, so if you wanted
a form to post back - but include or exclude a particular value from
the querystring you can alter the page's Location.QueryString collection
directly. This is in contrast to standard ASPX's Page.QueryString which
is read only.
You can also spawn and manipulate your own Location objects as and
when you need them, or Clone() them from the current page to start
with a Location that represents the current page, then alter the
querystring to suit, making for very simple construction of links
and actions without needing to do any string manipulation.
Once you've built up a Location object you can assign it to a Link
Href or even Response.Redirect to it by simply reading the
Href or RelativeHref string properties, no string concatanation neccesary.
| Qualifiers |
Type |
Name |
Default |
Description |
|
string |
Hash |
"" |
The named anchor within the page to navigate to, without a leading "#" - though you may set it with one. This will be "" when the Page loads because most browsers do not send it via http, but you can use it for link creation. |
|
string |
Host |
"" |
The site/hostname portion of the url. E.g. "www.example.com" |
|
string |
Path |
"" |
Any sub directory paths after the host, with a leading "/", though you may set it without one. E.g. "/virtdir/" |
|
string |
Page |
"" |
The page name, can be left empty to request the default page (i.e. "Default.aspx"). E.g. "About_Us.aspx" |
|
int |
Port |
80 |
The port number, if Protocol is "http" and Port is 80 then the port will not be rendered, the same applies for "ftp"/21 and "https"/443 |
|
string |
Protocol |
"http" |
The protocol that the link will use, without a trailing ":", though you may set it with one |
|
NameValueCollection |
QueryString |
(empty) |
The key/value pairs as found in the querystring, it is fully public so you can add and remove values from the collection as well as assign your own NameValueCollection directly by reference |
| readonly |
string |
Href |
|
Mirrors Javascript window.location.href, includes Protocol, Host and Port. Note: This is rebuilt every time the property is read, you may want to cache it in a local string if you need it more than once. |
| readonly |
string |
RelativeHref |
|
Mirrors Javascript window.location.href, excludes Protocol, Host and Port. Note: This is rebuilt every time the property is read, you may want to cache it in a local string if you need it more than once. |
| readonly |
string |
Search |
|
Mirrors Javascript window.location.search, includes leading "?" but excludes trailing Hash. Note: This is rebuilt every time the property is read, you may want to cache it in a local string if you need it more than once. |
| readonly |
string |
ToString() |
|
Equivelant to Href |