Madmike's Blog

September 6, 2009

How to integrate Dojo with ASP.net

Filed under: Asp.net,C#,Dojo,Programming — Florescu Radu @ 19:36
Tags: , , , ,

First steps

Start your visual studio 2008 (Start->Programs->Microsoft Visual Studio 2008->Microsoft Visual Studio 2008).And select Web Development Settings.Then click on Start visual Studio

Start a new Project (ASP.net Website)

<%@ Page AutoEventWireup=”true”  CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head runat=”server”>

<title>ASP.net and Dojo first example</title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

</div>

</form>

</body>

</html>

Now lets include the code that will allow us to use the dojo scripts.This code ussually goes in the head part.

<script src=”Dojo/dojo/dojo.js”                       djConfig=”parseOnLoad:true”></script>

<script>

dojo.require(“dojo.parser”);

</script>

Now we have everything ready to unleash the power of Dojo

This is the first example of Dojo

<%@ Page AutoEventWireup=”true”  CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head runat=”server”>

<title>ASP.net and Dojo first example</title>

<script type=”text/javascript” src=”Dojo/dojo/dojo.js” djConfig=”parseOnLoad:true”></script>

<script type=”text/javascript”>

//include the necessary files to use dojo parser and the button we use in the //body

dojo.require(“dojo.parser”);

dojo.require(“dijit.form.Button”);

</script>

//include some themes from dojo by default

<style type=”text/css”>

@import “Dojo/dijit/themes/tundra/tundra.css”;

@import “Dojo/dojo/resources/dojo.css”;

</style>

</head>

<body>

// we make a form with name myForm and an input button to type something in //it

<form id=”myForm” runat=”server”  method=”get” action=”Default.aspx”>

Please enter your name:

<input type=”text”/>

<div>

//this is a dijit.form.button

//sure you observer one new attributes here like : dojoType and the name of //the control : button

<button dojoType=”dijit.form.Button”>

Hello World!

<script type=”dojo/method” event=”onClick”>

alert(“bla”);

</script>

</button>

</div>

</form>

</body>

</html>

This is the output

Dojo tutorials

Many of them are good ,but I used this ones and there were very good:

http://www.roseindia.net/dojo/

http://www.dojotoolkit.org/forum/dojo-foundation/general-discussion/step-step-dojo-tutorials

And some books like this ones: dojo-using-the-dojo-javascript-library-to-build-ajax-applications-developers-library and practical-dojo-projects-practical-projects.

Your can also learn by doing with dojo book version 1.3

Links and references

You can also use this tutorial to see the things from other perspective :

http://www.codeproject.com/KB/ajax/Dojo-AjaxDotNet.aspx

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: