Notice that the example actually inherits from windows form control
452 | CHAPTER 15 |
|
---|
Listing 15.1 shows the code you’ll use to create the example in this section. Notice that the example actually inherits from a Windows form control, rather than a Web control. You’ll find this example in the \Chapter 15\SampleControl folder of the source code on the Sybex Web site.
Listing 15.1: |
---|
public String ResourceURL
{
get
{
// Return the string that the user provided as input or // nothing when the URL is invalid.if (_ResourceURL == null)
return "";
else
return _ResourceURL.AbsoluteUri;
}
set
{
// Use a try...catch block in case the user passes // something other than a valid URI.
CREATING A CONTROL | 453 |
---|
if (_ResourceURL == null)
return "0";
else
return _ResourceURL.Port.ToString(); }
}public Boolean IsValidURL
{
get
{
// Verify that the resource URL is valid. The _ResourceURL // variable is null when the URL is invalid.String TheData; // Contains the actual data.
// If the URL isn't valid, then return.
if (_ResourceURL == null)
return "";this.Text = "Getting the Response";
Response = (HttpWebResponse)Request.GetResponse();