ASP.Dot.NET.2.0.Revealed [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

ASP.Dot.NET.2.0.Revealed [Electronic resources] - نسخه متنی

Patrick A. Lorenz

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Fun Pet Trick #10: Data Binding the New BulletedList Control to an XML File


By Scott Guthrie

One of the new server controls in Whidbey is the BulletedList control, which enables you (not surprisingly) to display a list of bulleted items.

One of the nice features of the control is a displaymode property that enables you to toggle the control in a few interesting ways. The default value is text, which causes plain text to be rendered. You can also toggle it into HyperLink mode, which will generate hyperlinks.

A simple trick is to use the BulletedList control (in HyperLink mode) to generate a list of links to other sites within your page, by dynamically binding it to an XML file on disk (where the links are encapsulated).

The following example shows how to easily do this using the new DataSetDataSource control:


<%@ page language="VB" %>
<html>
<body>
<form runat="server">
<asp:bulletedlist id="BulletedList1" runat="server"
datatextfield="Name" datasourceid="DataSetDataSource1"
datavaluefield="Url" displaymode="HyperLink">
</asp:bulletedlist>
<br />
<br />
<asp:datasetdatasource id="DataSetDataSource1"
runat="server" datafile="MyLinks.xml">
</asp:datasetdatasource>
</form>
</body>
</html>

where the MyLinks.xml file is defined as follows:


<?xml version="1.0" encoding="utf-8" ?>
<Links>
<Link>
<Name>ASP.NET Site</Name>
<Url>http://www.asp.net</Url>
</Link>
<Link>
<Name>MSDN</Name>
<Url>http://msdn.microsoft.com</Url>
</Link>
<Link>
<Name>ASPAdvice</Name>
<Url>http://www.aspadvice.com</Url>
</Link>
</Links>

Updating the XML file on disk will then automatically update the list of links on your site.

A very simple trick—but kind of useful on content sites.

/ 133