Dojo starts three kinds of HelloWorld!

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

  1. <%@PageLanguage=“C#”AutoEventWireup< /span>=“true”CodeBehind=“HelloWorldDojo.aspx.cs”< /span>Inherits=“DojoTest.HelloWorldDojo”%>< /span>
  2. >< /span>
  3. <html xmlns=“http://www.w3.org/1999/xhtml”>< /span>
  4. <headrunat =“server”>
  5. <title>title> span>
  6. <%– Introduce Dojo–%>
  7. <scriptsrc =“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js”
  8. type =“text/javascript”>script >
  9. <scripttype=“text/javascript”>
  10. function init(){
  11. The click event from the function to the button //helloworld
  12. dojo.connect(dojo.byId(“mybutton) “), “onclick”, “helloworld”);
  13. function helloworld() {
  14. alert(“Hello World Dojo!!!”)
  15. dojo.ready(init);< /li>
  16. script< span class="tag" style="margin:0px; padding:0px; border:none; background-color:inherit">>
  17. head>
  18. <body>
  19. <inputid=“mybutton” type=“button” value=“HelloWorldDojo”/>
  20. body>
  21. html>

Dojo Operate the DOM version of HelloWorld

  1. <%@ PageLanguage=“C#” span>AutoEventWireup=“true”CodeBehind=“HelloDojo.aspx.cs”Inherits< span style="margin:0px; padding:0px; border:none; background-color:inherit">=“DojoTest.HelloDojo”%>
  2. >< /span>
  3. <htmlxmlns=“http://www.w3.org/1999/xhtml”>
  4. < headrunat span>=“server”>< /span>
  5. <title>title>
  6. <scriptsrc=” http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js”type=“text/javascript”>script>  
  7.     <script type=“text/javascript”>  
  8.         dojo.ready(function () {  
  9.             dojo.create(  
  10.                 “div”,  
  11.                 {  
  12.                     “innerHTML”: “Hello, World!”  
  13.                 },  
  14.                 dojo.body()  
  15.               );  
  16.         });  
  17.     script>  
  18. head>  
  19. <body>  
  20.     <h1>  
  21.         My First Dojo Program!h1>  
  22.     <div id=“message”>  
  23.         Hello,Dojo! div>  
  24. body >  
  25. html>  

Dojo封装Ajax实现HelloWorld

 

  1. <%@ Page Language=“C#” AutoEventWireup=“true” CodeBehind=“HelloDojoAjax.aspx.cs”  
  2.     Inherits=“DojoTest.HelloDojoAjax” %>  
  3.   
  4. >  
  5. <html xmlns=“http://www.w3.org/1999/xhtml”>  
  6. <head runat=“server”>  
  7.     <title>title>  
  8.     <script src=“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js” type=“text/javascript”>script>  
  9.     <script type=“text/javascript”>  
  10.   
  11.       function helloWorld(){  
  12.           dojo.xhrGet({  
  13.             url:”HelloDojo.txt”,//请求的服务器资源url  
  14.             handleAs:”text”,//返回的数据类型  
  15.             load:function(response,ioArgs){alert(response);},//成功后回调函数  
  16.             error:function(er ror,ioArgs){alert(error.message);}//出错时回调函数  
  17.           });  
  18.        }  
  19.   
  20.        //绑定页面加载完成后的初始化函数  
  21.        dojo.ready(helloWorld);  
  22.     script>  
  23. h ead>  
  24. <body>  
  25.      
  26. body>  
  27. html>  

最近对Ajax关注多一些,可能会出一些dojo有关ajax方面的文章。 dijit控件也可能谈一谈

  1. <%@ Page Language=“C#” AutoEventWireup=“true” CodeBehind=“HelloWorldDojo.aspx.cs” Inherits=“DojoTest.HelloWorldDojo” %>  
  2.   
  3. >  
  4.   
  5. <html xmlns=“http://www.w3.org/1999/xhtml”>  
  6. <head runat=“server”>< span style="margin:0px; padding:0px; border:none; background-color:inherit">  
  7.     <title>title>  
  8.         <%– 引入 Dojo–%>  
  9.     <script src=“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js”  
  10.         type=“text/javascript”>script>  
  11.   
  12.     <script type=“text/javascript”>  
  13.         function init() {  
  14.             //helloworld 函数到按钮的点击事件  
  15.             dojo.connect(dojo.byId(“mybutton”), “onclick”, “helloworld”);  
  16.         }  
  17.   
  18.         function helloworld() {   
  19.             alert(“Hello World Dojo!!!”)  
  20.         }  
  21.   
  22.         dojo.ready(init);  
  23.     script>  
  24. head>  
  25. <body>  
  26.    <input id=“mybutton” type=“button” value=“HelloWorldDojo” />  
  27. body>  
  28. html>  
  1. <%@ Page Language=“C#” AutoEventWireup=“tr ue” CodeBehind=“HelloDojo.aspx.cs” Inherits=“DojoTest.HelloDojo” %>  
  2.   
  3. >  
  4. <html xmlns=“http://www.w3.org/1999/xhtml” >  
  5. <head runat=“server”>  
  6.     <title>title>  
  7.     <script src=“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js” type=“text/javascript”>script>  
  8.     <script type=“text/javascript”>  
  9.         dojo.ready(function () {  
  10.             dojo.create(  < /span>
  11.                 “div”,  
  12.                 {  
  13.                     “innerHTML”: “Hello, World!”  
  14.                 },  
  15.                 dojo.body()  
  16.               );  
  17.         });  
  18.     script>  
  19. head>  
  20. <body>  
  21.     <h1>  
  22.         My First Dojo Program!h1>  
  23.     <div id=“message”>  
  24.         Hello,Dojo! div>  
  25. body>   
  26. html>  
  1. <%@ Page Language=“C#” AutoEventWireup=“true” CodeBehind=“HelloDojoAjax.aspx.cs”  
  2.     Inherits=“DojoTest.HelloDojoAjax” %>  
  3.   
  4. >  
  5. <html xmlns=“http://www.w3.org/1999/xhtml”>  
  6. <head runat=“server”>  
  7.     <title>title>  
  8.     <script src=“http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js” type=“text/javascript”>script>  
  9.     <script type=“text/javascript”>  
  10.   
  11.       function helloWorld(){  
  12.           dojo.xhrGet({  
  13.             url:”HelloDojo.txt”,//请求的服务器资源url  
  14.             handleAs:”text”,//返回的数据类型  
  15.             load:function(response,ioArgs){alert(response);},//成功后回调函数  
  16.             error:function(error,ioArgs){alert(error.message);}//出错时回调函数  
  17.           });  
  18.        }  
  19.   
  20.        //绑定页面加载完成后的初始化函数  
  21.        dojo.ready(helloWorld);  
  22.     script>  
  23. head>  
  24. <body>  
  25.      
  26. body>  
  27. html>  

Leave a Comment

Your email address will not be published.