Monday, 11 February 2013

Random Color Generator in JavaScript



<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Generate Random Colors using javascript</title>
<script type="text/javascript">
// Run function for every second of timer
setInterval(rgbcolors, 1000);
function rgbcolors() {
// rgb string generation
var col = "rgb("
+ Math.floor(Math.random() * 255) + ","
+ Math.floor(Math.random() * 255) + ","
+ Math.floor(Math.random() * 255) + ")";
//change the text color with the new random color
document.getElementById("divstyle").style.color = col;
}
</script>
</head>s
<body>
<form id="form1" runat="server" >
<div id="divstyle" style="font:bold 24px verdana">http://dotnetdatastuff.blogspot.in/</div>
</form>
</body>
</html>

Monday, 4 February 2013

jQuery Get Current Page URL

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Curent Page Url using jQuery in Asp.net</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function () {
var url = $(location).attr('href');
var title= $(this).attr('title');
$('#spn_title').html('<strong>' + title + '</strong>');
$('#spn_url').html('<strong>' + url + '</strong>');
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Current page URL: <span id="spn_url"></span>.</p>
<p>Current page title: <span id="spn_title"></span>.</p>
</div>
</form>
</body>
</html>

Tuesday, 22 January 2013

Difference between JavaScript and jQuery



S.No
JavaScript
jQuery
1
Meaning:

JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari.
Meaning:

JQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
2
Composed of:

JavaScript is a combination of ECMA Script and Document Object Model (DOM).
Composed of:

jQuery has Document Object Model (DOM).
3
Web-based application creation:

JavaScript has many processes in creating web based applications.

Example:
Two JavaScript function to change the background color with the onload function that would need to placed into the body tag

function changeBackground(color) {
document.body.style.background = color;
}
onload="changeBackground('red');"

Note:
If we use this unstructured code then there is many problems to validate the html source of web page. So JQuery is best to use and easy to understand.
Web-based application creation:

Creating a web based application using jQuery becomes easier.

Example:
One JQuery changing the background color of a body tag

$('body').css('background', '#ccc');

This is the clean code JQuery provides.
4
Animation Creation:

Animations are not possible using JavaScript.
Animation Creation:

Animations can be easily created using jQuery.

Sunday, 4 November 2012

How to find Empty Data in DataList Control




01<asp:DataList ID="dlContacts" runat="server">
02<ItemTemplate>
03
04<!-- Add your Item Template Here -->
05
06</ItemTemplate>
07<FooterTemplate>
08<asp:Label ID="lblEmpty" Text="no result" runat="server"
09     Visible='<%#bool.Parse((dlContacts.Items.Count==0).ToString())%>'>
10</asp:Label>
11</FooterTemplate>
12</asp:DataList>

Convert SVG to PNG using svg.dll

      <div id="divsvg">        <svg width="350" height="300"><defs></defs> ............