I have been learning Dojo for some time, and I have compiled some materials, let’s start with the most introductory level. HelloWorld
Asp.Net+Dojo
Dojo event binding, pop up HelloWorld
- <%@PageLanguage=“C#”AutoEventWireup< /span>=“true”CodeBehind=“HelloWorldDojo.aspx.cs”< /span>Inherits=“DojoTest.HelloWorldDojo”%>< /span>
- >< /span>
- <html xmlns=“http://www.w3.org/1999/xhtml”>< /span>
- < span>headrunat =“server”> li>
- <title>title> span>
- <%– Introduce Dojo–%>
- < span>scriptsrc =“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js”
- type =“text/javascript”>script >
- <scripttype=“text/javascript”>
- function init(){
- The click event from the function to the button //helloworld
- dojo.connect(dojo.byId(“mybutton) “), “onclick”, “helloworld”);
- function helloworld() {
- alert(“Hello World Dojo!!!”)
- dojo.ready(init);< /li>
- script< span class="tag" style="margin:0px; padding:0px; border:none; background-color:inherit">>
- head>
- <body>
- <inputid=“mybutton” type=“button” value=“HelloWorldDojo”/>
- body>
- html>
Dojo Operate the DOM version of HelloWorld
- < span>%@ PageLanguage=“C#” span>AutoEventWireup=“true”CodeBehind=“HelloDojo.aspx.cs”Inherits< span style="margin:0px; padding:0px; border:none; background-color:inherit">=“DojoTest.HelloDojo”%>
- >< /span>
- <htmlxmlns=“http://www.w3.org/1999/xhtml”>
- < headrunat span>=“server”>< /span>
- <title>title>
- <scriptsrc=” http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js”type=“text/javascript”>script> li>
- <script type=“text/javascript”>
- dojo.ready(function () {
- dojo.create(
- “div”,
- {
- “innerHTML”: “Hello, World!”
- },
- dojo.body()
- );
- });
- script>
- head>
- <body>
- <h1>
- My First Dojo Program!h1>
- <div id=“message”>
- Hello,Dojo! div>
- body >
- html>
Dojo封装Ajax实现HelloWorld
- <%@ Page Language=“C#” AutoEventWireup=“true” CodeBehind=“HelloDojoAjax.aspx.cs”
- Inherits=“DojoTest.HelloDojoAjax” %>
- >
- <html xmlns=“http://www.w3.org/1999/xhtml”>
- <head runat=“server”>
- <title>title>
- <script src=“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js” type=“text/javascript”>script>
- <script type=“text/javascript”>
- function helloWorld(){
- dojo.xhrGet({
- url:”HelloDojo.txt”,//请求的服务器资源url
- handleAs:”text”,//返回的数据类型
- load:function(response,ioArgs){alert(response);},//成功后回调函数
- error:function(er ror,ioArgs){alert(error.message);}//出错时回调函数
- });
- }
- //绑定页面加载完成后的初始化函数
- dojo.ready(helloWorld);
-
script> - h ead>
- <body>
- body>
- html>
最近对Ajax关注多一些,可能会出一些dojo有关ajax方面的文章。 dijit控件也可能谈一谈
- <%@ Page Language=“C#” AutoEventWireup=“true” CodeBehind=“HelloWorldDojo.aspx.cs” Inherits=“DojoTest.HelloWorldDojo” %>
- >
- <html xmlns=“http://www.w3.org/1999/xhtml”>
- <head runat=“server”>< span style="margin:0px; padding:0px; border:none; background-color:inherit">
- <title>title>
- <%– 引入 Dojo–%>
- <script src=“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js”
- type=“text/javascript”>script>
- <script type=“text/javascript”>
- function init() {
- //helloworld 函数到按钮的点击事件
- dojo.connect(dojo.byId(“mybutton”), “onclick”, “helloworld”);
- }
- function helloworld() {
- alert(“Hello World Dojo!!!”)
- }
- dojo.ready(init);
- script>
- head>
- <body>
- <input id=“mybutton” type=“button” value=“HelloWorldDojo” />
- body>
- html>
- <%@ Page Language=“C#” AutoEventWireup=“tr ue” CodeBehind=“HelloDojo.aspx.cs” Inherits=“DojoTest.HelloDojo” %>
- >
- <html xmlns=“http://www.w3.org/1999/xhtml” >
- <head runat=“server”>
- <title>title>
- <script src=“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js” type=“text/javascript”>script>
- <script type=“text/javascript”>
- dojo.ready(function () {
- dojo.create( < /span>
- “div”,
- {
- “innerHTML”: “Hello, World!”
- },
- dojo.body()
- );
- });
- script>
- head>
- <body>
- <h1>
- My First Dojo Program!h1>
- <div id=“message”>
- Hello,Dojo! div>
- body>
- html>
- <%@ Page Language=“C#” AutoEventWireup=“true” CodeBehind=“HelloDojoAjax.aspx.cs”
- Inherits=“DojoTest.HelloDojoAjax” %>
- >
- <html xmlns=“http://www.w3.org/1999/xhtml”>
- <head runat=“server”>
- <title>title>
- <script src=“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js” type=“text/javascript”>script>
- <script type=“text/javascript”>
- function helloWorld(){
- dojo.xhrGet({
- url:”HelloDojo.txt”,//请求的服务器资源url
- handleAs:”text”,//返回的数据类型
- load:function(response,ioArgs){alert(response);},//成功后回调函数
- error:function(error,ioArgs){alert(error.message);}//出错时回调函数
- });
- }
- //绑定页面加载完成后的初始化函数
- dojo.ready(helloWorld);
- script>
- head>
- <body>
- body>
- html>