Firefox 2.0 リリース
Firefox 2.0がリリースされています。
ダウンロードはこちら。
IE7も英語版はリリースされていますので、日本語版ももうじきでしょう。
| 固定リンク | コメント (0) | トラックバック (0)
Firefox 2.0がリリースされています。
ダウンロードはこちら。
IE7も英語版はリリースされていますので、日本語版ももうじきでしょう。
| 固定リンク | コメント (0) | トラックバック (0)
| 固定リンク | コメント (0) | トラックバック (0)
<asp:XmlDataSource ID="dataSource" DataFile="~/Data.xml"
XPath="/Data/Node" runat="server">
<Transform>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:for-each select="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
</Transform>
</asp:XmlDataSource>
<?xml version="1.0" encoding="UTF-8" ?>
<Results xmlns="jws">
.....
</Results>
のように、名前空間が付加されています。
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TreeView Example 2</title>
</head>
<body>
<form id="form1" runat="server">
<div>じゃらん Webサービス エリアデータ</div>
<div style="border:solid 1px black;width:300px;">
<asp:TreeView ID="areaTree" ExpandDepth="0"
DataSourceID="dataSource" runat="server">
<DataBindings>
<asp:TreeNodeBinding DataMember="Region"
TextField="name" ValueField="cd" SelectAction="Expand"
PopulateOnDemand="True" />
<asp:TreeNodeBinding DataMember="Prefecture"
TextField="name" ValueField="cd" SelectAction="Expand"
PopulateOnDemand="True" />
<asp:TreeNodeBinding DataMember="LargeArea"
TextField="name" ValueField="cd" SelectAction="Expand"
PopulateOnDemand="True" />
<asp:TreeNodeBinding DataMember="SmallArea"
TextField="name" ValueField="cd" />
</DataBindings>
</asp:TreeView>
</div>
<asp:XmlDataSource ID="dataSource"
DataFile="http://jws.jalan.net/APICommon/AreaSearch/V1/?key=APIキー"
XPath="/Results/Area/Region" runat="server">
<Transform>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:for-each select="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
</Transform>
</asp:XmlDataSource>
</form>
</body>
</html>
データ量が結構多いので、TreeViewのExpandDepthを0にして初期表示では要素を展開しないようにし、
asp:TreeNodeBindingのPopulateOnDemandをTrueにして動的にバインドさせています。
| 固定リンク | コメント (0) | トラックバック (0)
<?xml version="1.0" encoding="utf-8" ?>
<data>
<WebSites>
<WebSite name="Microsoft" url="http://www.microsoft.com/japan/">
<Contents title="MSDN" url="http://www.microsoft.com/japan/msdn/" />
<Contents title="Visual Studio"
url="http://www.microsoft.com/japan/msdn/vstudio/" />
</WebSite>
<WebSite name="Google" url="http://www.microsoft.com/japan/">
<Contents title="Google Map" url="http://maps.google.co.jp/" />
<Contents title="Google Calendar" url="http://www.google.com/calendar/" />
</WebSite>
<WebSite name="Yahoo! Japan" url="http://www.yahoo.co.jp/">
<Contents title="Yahoo! Developer Network" url="http://developer.yahoo.co.jp/" />
</WebSite>
</WebSites>
</data>
これをTreeViewにバインドする場合、ASPXファイルは以下のような記述となります。
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TreeView Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TreeView ID="siteTree" DataSourceID="siteDataSource" runat="server">
<DataBindings>
<asp:TreeNodeBinding DataMember="WebSite"
TextField="name" ValueField="url" />
<asp:TreeNodeBinding DataMember="Contents"
TextField="title" ValueField="url" />
</DataBindings>
</asp:TreeView>
</div>
<asp:XmlDataSource ID="siteDataSource"
DataFile="~/Data.xml"
XPath="/data/WebSites/WebSite"
runat="server"></asp:XmlDataSource>
</form>
</body>
</html>
まずXmlDataSourceの方では、DataFileプロパティにデータへのパスを設定します。| 固定リンク | コメント (0) | トラックバック (0)
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public string TestMethod()
{
return "Hello Atlas";
}
}
WebMethodという属性はWebサービスで公開するメソッドにつける属性ですが、Atlasではaspxでこの属性の付いたメソッドをクライアントの
JavaScriptから呼び出せるようです。
<script type="text/javascript">
window.onload = function()
{
PageMethods.TestMethod(RequestComplete);
}
function RequestComplete(data)
{
alert(data);
}
</script>
PageMethods.TestMethod(RequestComplete);<atlas:ScriptManager ID="ScriptManager1" runat="server" />の部分によってクライアントにJavaScriptが出力されています。
| 固定リンク | コメント (0) | トラックバック (0)