分享
 
 
 

Exploring the Internet Explorer WebControls...

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

By: John Kilgo

Date: February 23, 2003
Download the code.
Printer Friendly Version

You may not be familiar with the IE WebControls. That is because they are not part of the installation of the .Net framework or Visual Studio.Net. You must download them from Microsoft. They are available for download at http://msdn.microsoft.com/downloads/samples/internet/asp_dot_net_servercontrols/webcontrols/. Documentation for the controls is available at http://msdn.microsoft.com/workshop/webcontrols/webcontrols_entry.asp.

Treeview, Toolbar, and TabStrip controls have been a part of client-server applications for years. They are not as common on the web due to the dhtml involved. Actually, for the most part, Microsoft has implemented dhtml for these controls only if you are running IE 5.5 and above. Downlevel browsers such as Netscape, and earlier IE implementations make multiple trips to the server rather than serving dhtml for these controls. We will explore the controls and ask the question: are they ready for prime time?

First we will examine the TreeView control. The example program presented below contains three TreeView controls. The first is just a simple implementation that doesn't do anything other than display some data. The second example utilizes the NavigateUrl property to form a vertical navigation menu. It also includes the DefaultStyle property to control display coloring and border when first expanded. When you hover over the expanded nodes, it reverts to the default coloring and lack of a border. I never could figure out how to control the coloring of the top node. I guess Microsoft allows it to be any color you want as long as it is pale blue. The third example binds the nodes to the contents of an xml file. While this may be neat, I'm not sure what it buys you. I should also point out that these controls must be registered on the page. That is what the second line of code does.

<%@ Page Language="vb" %>

<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"

Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>TreeView</title>

<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">

<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">

<meta name=vs_defaultClientScript content="JavaScript">

<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">

</head>

<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

Simple Treeview<br>

<iewc:TreeView id="TreeView1" runat="server">

<iewc:TreeNode text="My Favorite .Net Books" runat="server" ID="Treenode1" NAME="Treenode1">

<iewc:TreeNode text="ASP.NET Unleashed - Stephen Walther" />

<iewc:TreeNode text="Programming Data-Driven Web Applications with ASP.NET - Donny Mack & Doug Seven" />

</iewc:TreeNode>

</iewc:TreeView>

<p>

Treeview with URL Navigation<br>

<iewc:TreeView id="TreeView2" runat="server" >

<iewc:treenode text="URL Navigation">

<iewc:treenode text="Microsoft.com"

NavigateUrl="http://www.microsoft.com"

DefaultStyle="background: #CCCCCC; border: solid 1px; color: Black; font-size: 10pt" />

<iewc:treenode text="dotnetjohn.com"

NavigateUrl="http://www.dotnetjohn.com"

DefaultStyle="background: #CCCCCC; border: solid 1px; color: Black; font-size: 10pt" />

</iewc:treenode>

</iewc:TreeView>

</p>

<p>

Treeview with XML Source<br>

<iewc:TreeView id="TreeView3" runat="server" TreeNodeSrc="JazzPiano.xml">

</iewc:TreeView>

</p>

</form>

</body>

</html>

The code for the xml file used in the third example is shown below.

<TREENODES>

<TREENODE Text="Favorite Jazz Pianists">

<TREENODE Text="Oscar Peterson">

</TREENODE>

<TREENODE Text="Keith Jarrett">

</TREENODE>

<TREENODE Text="Bill Evans">

</TREENODE>

</TREENODE>

</TREENODES>

You may run the TreeView example program here.

Next we will look at the ToolBar control. Although it also has a limited number of properties and methods, you can do some useful things with it. The example program demonstrates two ways to handle events with the ToolBar control. The first example checks the button click event to change the fore color of a label control. The second example implements a horizontal menuing system. All in all I found the toolbar to have some useful features although it also is short on properties and methods.

<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"

Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

<%@ Page Language="vb" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>ToolBar</title>

<Script runat="server">

Sub btn_Click(sender As Object, e As EventArgs)

Select Case btnGroup.SelectedCheckButton.Text

Case "Red"

lblMessage.ForeColor = System.Drawing.Color.Red

Case "Green"

lblMessage.ForeColor = System.Drawing.Color.Green

Case "Blue"

lblMessage.ForeColor = System.Drawing.Color.Blue

End Select

End Sub

Sub Button_Click(sender As Object, e As EventArgs)

Select Case sender.id.ToString()

Case "books"

Response.Redirect("http://www.dotnetjohn.com/books.aspx")

Case "links"

Response.Redirect("http://www.dotnetjohn.com/links.aspx")

Case "home"

Response.Redirect("http://www.dotnetjohn.com/")

Case "about"

Response.Redirect("http://www.dotnetjohn.com/about.aspx")

End Select

End Sub

</Script>

<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">

<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">

<meta name=vs_defaultClientScript content="JavaScript">

<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">

</head>

<body>

<form id="Form1" method="post" runat="server">

Simple Toolbar with Events

<iewc:Toolbar id="Toolbar1" runat="server" width="100px" AutoPostBack="True" OnButtonClick="btn_Click">

<iewc:ToolbarCheckGroup id="btnGroup">

<iewc:ToolBarCheckButton Text="Red" />

<iewc:ToolBarCheckButton Text="Blue" />

<iewc:ToolBarCheckButton Text="Green" />

</iewc:ToolbarCheckGroup>

</iewc:Toolbar>

<p>

<asp:Label ID="lblMessage" Runat="server" Text="This is your color" />

</p>

<div align="center>

Toolbar as a Navigation Menu

<iewc:Toolbar id="Toolbar2" runat="server" onButtonClick="Button_Click" width="225px">

<iewc:ToolbarSeparator />

<iewc:ToolbarButton text="Books" id="books" />

<iewc:ToolbarSeparator />

<iewc:ToolbarButton text="Links" id="links" />

<iewc:ToolbarSeparator />

<iewc:ToolbarButton text="Home" id="home" />

<iewc:ToolbarSeparator />

<iewc:ToolbarButton text="About" id="about" />

<iewc:ToolbarSeparator />

</iewc:Toolbar>

</div>

</form>

</body>

</html>

You may run the ToolBar example program here.

Lastly we will look at the TabStrip control. I found this control to be very frustrating to set up and to have limited usefulness. I present my efforts below and hope that you can do better. Please note that to get anything other than the tab strips themselves (the headings) you must also include a MultiPage control.

<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"

Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>TabStrip</title>

<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">

<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">

<meta name=vs_defaultClientScript content="JavaScript">

<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">

</head>

<body>

<form id="Form1" method="post" runat="server">

<iewc:TabStrip id=TabStrip2 runat="server"

style="width:400px; height:100%;"

TabSelectedStyle="background-color:#ffffff;color:#000000"

TabHoverStyle="background-color:#777777"

SepDefaultStyle="width:10px; border-bottom: solid 1px red;"

TabDefaultStyle="background-color:#000000; border:solid 1px red; font-family:verdana; font-weight:bold; font-size:8pt; color:#ffffff; width:79; height:21; text-align:center"

TargetID="mpcTabs">

<iewc:Tab Text="Tab 1" />

<iewc:TabSeparator />

<iewc:Tab Text="Tab 2" />

<iewc:TabSeparator />

<iewc:Tab Text="Tab 3" />

</iewc:TabStrip>

<iewc:MultiPage id="mpcTabs" runat="server"

style="BORDER-RIGHT:red 1px solid; PADDING-RIGHT:12px; BORDER-TOP:medium none; PADDING-LEFT:12px; PADDING-BOTTOM:12px; BORDER-LEFT:red 1px solid; PADDING-TOP:12px; BORDER-BOTTOM:red 1px solid" Width="400px" Height="81px">

<iewc:PageView>

MultiPage One

</iewc:PageView>

<iewc:PageView>

MultiPage Two

</iewc:PageView>

<iewc:PageView>

MultiPage Three

</iewc:PageView>

</iewc:MultiPage>

</form>

</body>

</html>

You may run the TabStrip example program here.

At the top of the article I posed the question: are these IEWebControls ready for prime time? For me, the answer is no. While Microsoft is to be lauded for making the controls available, I believe they need a lot more work to make them truly useful on the web. They are simply not "fat" enough to be included with the rest of the .Net server controls. The one possible exception may lie in using the TreeView and ToolBar controls for page navigation.

You may download the code here. Don't forget that before you can run the programs you must download the controls at the link provided at the top of the article.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有