Dojo入門三種HelloWorld!

來源:互聯網
上載者:User

學習Dojo有些時間了,也整理了一些資料,先來個最入門層級的。HelloWorld

Asp.Net+Dojo

 

Dojo事件綁定,彈出HelloWorld

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HelloWorldDojo.aspx.cs" Inherits="DojoTest.HelloWorldDojo" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <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>

Dojo操作DOM版HelloWorld

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HelloDojo.aspx.cs" Inherits="DojoTest.HelloDojo" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><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(                "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" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><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>

最近對Ajax關注多一些,可能會出一些dojo有關ajax方面的文章。dijit控制項也可能談一談

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.