HOME BUILDER
JAMES HEIN
Before we start, I have a question: Why would you build a new web site and only make it IE compatible? The answer is that you shouldn't, especially as a business.
Yet that is what True UBC has done with its new site "True Visions." I guess the vision is to restrict access and so True gets this week's bad local web site award. The problem is IE-only supported controls like tab panels. Microsoft has too much proprietary stuff in what is supposed to be an open environment.
This week we look at Microsoft Web Server Controls (WSC). These give you more control and a more "Microsoft consistent" programming model. A complex web server control might be the calendar control or a full data grid. A web server control will also sometimes detect the capabilities of the browser and render appropriately. This refers to Microsoft browsers, with some limited support for others.
A quick search on Microsoft's site did not give any details other than the following statement: "The WebControls provide an authoring solution with widespread reach, by delivering HTML 3.2 compatible content to downlevel browsers (Internet Explorer 5.01 or earlier or a browser other than Internet Explorer). ASP.NET Web forms detect the client browser capabilities and include DHTML behaviors in the Web pages downloaded to uplevel browsers (Internet Explorer 5.5 or later)."
This means that you may need to do testing on Opera, Mozilla and Mac browsers if you want broad useability.
In Visual Studio 2005 these controls are found under the "Standard" label. Careful, as this means Microsoft's standards - not necessarily the universal ones.
Create a project and drop a Calendar control onto your blank page. Click on run and see what happens. I got a weird error the first time I tried this under Firefox but it worked okay the second time. Adding a calendar control to your web pages is this easy. You may have a lot of programming code to write as the event handlers but the control is simple.
You can drop a new control directly into the source view or you can dynamically create a control in the page behind code's PageInit method.
Protected Sub PageInit etc.
Dim c as New TextBox()
c.ID = "txtUserName
c.Visible = True
form1.Controls.Add(c)
End Sub
When the page initialises a text box object will be created, given the ID of txtUserName, made visible and added to the form's Controls collection. Every WSC must have a valid ID to allow you to programmatically reference it.
Each WSC has a common set of properties like BackColor, Height, Width and so on. As already seen, you can set these under program control or by right clicking on the control and then Properties to see all of the properties valid for that particular control.
Try this for the calendar control. Note that an ID was automatically assigned and that you have control over a lot of properties. Now select the source view and select Calendar1 in the left hand drop down at the top of the source page. The list of available methods is now shown in the right hand drop down.
You enter your code under events like VisibleMonthChanged or SelectionChanged. If you double click on the calendar you will see that the default event is Selection Changed, that is someone has clicked on a date number.
Have a play with the properties like the back ground colour for today's date and note that the changes will dynamically be shown in your design view. You can make similar changes across any web control, limited of course to the available list for that control.
A reminder for web developers here is that the .NET framework is proprietary Microsoft. The web server you are using will need to support this framework at the version to which you are writing code.
To date there have been three versions - 1.0, 1.1 and 2.0, with I suspect a new version due out this year. Writing 2.0 will not work on a server loaded with 1.1, though the reverse should not cause any problems. Distributing .NET applications for a client PC will also typically require the relevant Framework installed, as I found out a while back when I tried to install and run a .NET based application.
Email: jamesh@inet.co.th
Prev
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Next