Dojo入门三种HelloWorld!

学习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控件也可能谈一谈

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值