How to create a button in DART web application

In this article, I am going to explain how to create a button, and how fire a event on created button.
  • 2295

Creating a button in a DART application

In a DART application you can create your own controls like button and whatever you want. for creating a simple web application using a button is given below

Syntax of creating a button

var varname=new Element.tag("varname"); i.e var button = new Element.tag("button");

Example of dart application

#import('dart:html');

 

void main() {

var button = new Element.tag("button");

button.text = "Click me";

button.on.click.add((event) {

List buttonList = document.queryAll("button");

window.alert("There is ${buttonList.length} button");

});

document.body.nodes.add(button);
}


You can simply run that program by manage and launch application in run option.

Output is ,when you run the program:

butt1.jpg


Output after click the button:

butt2.jpg
 

Ask Your Question 
 
Got a programming related question? You may want to post your question here
 
© 2013 dotNetheaven. All rights reserved.