Pages

Ads 468x60px

For New Update Use this Link http://dotnethubs.blogspot.in/ Offer for you

.

Saturday 16 March 2013

jquery and javascript


What is jQuery ?

jQuery is a fast and concise JavaScript Library created by John Resig in 2006 with a nice motto: Write less, do more.
jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
jQuery is a JavaScript toolkit designed to simplify various tasks by writing less code. Here is the list of important core features supported by jQuery:
  • DOM manipulation: The jQuery made it easy to select DOM elements, traverse them and modifying their content by using cross-browser open source selector engine called Sizzle.
  • Event handling: The jQuery offers an elegant way to capture a wide variety of events, such as a user clicking on a link, without the need to clutter the HTML code itself with event handlers.
  • AJAX Support: The jQuery helps you a lot to develop a responsive and feature-rich site using AJAX technology.
  • Animations: The jQuery comes with plenty of built-in animation effects which you can use in your websites.
  • Lightweight: The jQuery is very lightweight library - about 19KB in size ( Minified and gzipped ).
  • Cross Browser Support: The jQuery has cross-browser support, and works well in IE 6.0+, FF 2.0+, Safari 3.0+, Chrome and Opera 9.0+
  • Latest Technology: The jQuery supports CSS3 selectors and basic XPath syntax.

Friday 15 March 2013

Install Mongo on CentOS,Fedora, Ubuntu & Debian

Install MongoDB 2.0.4 on RHEL CentOS Fedora Ubuntu & Debian
This howto guide shows how to install MongoDB 2.0.4 on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16/15/14/13/12, Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian using MongoDB own YUM repositories for RHEL, CentOS and Fedora and apt-get for Ubuntu and Debian.

What is MongoDB?

MongoDB (from "humongous") is an open source scalable, high-performance and schema-free document-oriented NoSQL database system written in C++. MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide structured schemas and powerful queries).

MongoDB Features

  1. Document-oriented storage (the simplicity and power of JSON-like data schemas)
  2. Dynamic queries
  3. Full index support, extending to inner-objects and embedded arrays
  4. Query profiling
  5. Fast, in-place updates
  6. Efficient storage of binary data large objects (e.g. photos and videos)
  7. Replication and fail-over support
  8. Auto-sharding for cloud-level scalability
  9. MapReduce for complex aggregation
  10. Commercial Support, Training, and Consulting

Why MongoDB?

  1. Document-oriented
    1. Documents (objects) map nicely to programming language data types
    2. Embedded documents and arrays reduce need for joins
    3. Dynamically-typed (schemaless) for easy schema evolution
    4. No joins and no multi-document transactions for high performance and easy scalability
  2. High performance
    1. No joins and embedding makes reads and writes fast
    2. Indexes including indexing of keys from embedded documents and arrays
    3. Optional streaming writes (no acknowledgements)
  3. High availability
    1. Replicated servers with automatic master failover
  4. Easy scalability
    1. Automatic sharding (auto-partitioning of data across servers)
      1. Reads and writes are distributed over shards
      2. No joins or multi-document transactions make distributed queries easy and fast
    2. Eventually-consistent reads can be distributed over replicated servers
  5. Rich query language
Install MongoDB 2.0.4 on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12, Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian

How to Install MongoDB 2.0.4 RHEL, CentOS and Fedora

Step 1: Adding 10gen MongoDB Repository

Add 10gen Mongodb-repo (yum-installable RPM packages) on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12 for x86 and x86_64 platforms.

For all 32-bit RPM-based distros with yum, put this at /etc/yum.repos.d/10gen.repo:
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/
redhat/os/i686
gpgcheck=0
For all 64-bit RPM-based distros with yum, put this at /etc/yum.repos.d/10gen.repo:
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/
redhat/os/x86_64
gpgcheck=0

Step 2: Installing MongoDB 2.0.4

Installing MongoDB Database Server on RHEL 6.2/6.1/6/5.8, CentOS 6.2/6.1/6/5.8, Fedora 16-12 for x86 and x86_64 platforms using YUM.
yum install mongo-10gen mongo-10gen-server
Note: for users upgrading from older (pre-2/2011) packaging scheme, it may be necessary to uninstall your existing "mongo-stable", "mongo-stable-server", "mongo-unstable", "mongo-unstable-server" packages before installing the latest mongo-10gen, mongo-10gen-server pacakges.

Step 3: Configure MongoDB Database Server

Open and edit /etc/mongod.conf file with VI Editor. Verify and set basic settings, before starting MongoDB Database Server.
vi /etc/mongod.conf
logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo

Step 4: Starting MongoDB Database Server

/etc/init.d/mongod start
## OR ##
service mongod start

Step 5: Testing MongoDB Database Server

Testing with MongoDB command line client.
mongo

Step 6: Executing MongoDB Basic Commands

> show dbs
> show collections
> show users
> use <db name>

Step 7: Starting & Stopping MongoDB

Here is a quick reference to the commands that control the execution of the mongod server process:
service mongodb status 
service mongodb stop
service mongodb start
service mongodb restart
## OR ##
/etc/init.d/mongod status
/etc/init.d/mongod stop
/etc/init.d/mongod start
/etc/init.d/mongod restart

Step 8: Opening MongoDB Port on Firewall

Open file /etc/sysconfig/iptables and add the following line at the bottom and restart iptables.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 
-j ACCEPT
/etc/init.d/iptables restart
## OR ##
service iptables restart

Step 9: Testing MongoDB Remote Connection

mongo serverip:port/databasename
## Example ##
mongo 192.168.1.21:27017/ravisaive

How to Install MongoDB 2.0.4 on Ubuntu and Debian

Step 1: Adding 10gen MongoDB source.list

The 10gen package contains the latest mongoDB version, add below lines at the bottom of the file “/etc/apt/sources.list” on Ubuntu 12.04/11.10/11.04/10.10/10.04 and Debian.

For Ubunut, put these below lines to “/etc/apt/sources.list”:
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart 
dist 10gen
For Debian, put these below lines to “/etc/apt/sources.list”:
deb http://downloads-distro.mongodb.org/repo/debian-sysvinit 
dist 10gen

step 2: Adding GPG Key

10gen package required GPG key, import it:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 
7F0CEB10

step 3: Insalling MongoDB

sudo apt-get update 
sudo apt-get install mongodb-10gen

step 4: Starting MongoDB

sudo status mongodb
sudo stop mongodb
sudo start mongodb
sudo restart mongodb

step 5: Testing MongoDB

To verify it, just connect it with “mongo
mongo
In case you're facing any difficulties while setting up MongoDB Database Server, please share with us via comment.

Enable or Disable a Controls Like Button, Textbox, Checkbox

JavaScript - Enable or Disable a Controls Like Button, Textbox, Checkbox

JavaScript - Enable or Disable a Controls Like Button, Textbox, Checkbox

Categories:  Javascript | Jquery

                  
Introduction

Here I will explain how to enable or disable a button control in JavaScript or Enable/Disable a controls in JavaScript. 

Description:
  
In previous articles I explained JavaScript Enable/Disable button based on text in textboxes,
jQuery Shake image on mouse over, jQuery upload multiple files usingmultiple file upload plugin, jQuery fancy switch on and off effectsexample and many articles relating to JavaScript, jQuery, asp.net. Now I will explain how to enable or disable a button control in JavaScript.
To set controls enable or disable in JavaScript we need to write the code like as shown below

Enable control in JavaScript
document.getElementById('btnButton').disabled = false;
Disable control in JavaScript
document.getElementById('btnButton').disabled = true;
If you want to see it in complete example check this code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Enable or Disable a control in javascript</title>
<script language="javascript" type="text/javascript">
//function to enable button if two textboxes contains text
function SetButtonStatus() {
var txt = document.getElementById('txtfirst');
//Condition to check whether user enters text in two textboxes or not
if (txt.value.length >= 1)
document.getElementById('btnButton').disabled = false;
else
document.getElementById('btnButton').disabled = true;
}
</script>
</head>
<body>
<div>
<input type="text" id="txtfirst" onkeyup="SetButtonStatus(this,'btnButton')"/>
<input type="button" id="btnButton" value="Button" disabled="disabled" />
</div>
</body>
</html>
Live Demo

For live demo enter text in textbox whenever we enter text button will enable otherwise it’s in disable mode


Enter Text   Button

database normalization with example

jquery in asp.net

First Normal Form (1NF): No repeating elements or groups of elements

Don’t repeat your columns. Avoid this:

OrderId ItemId1 ItemId2
1 100 101
ItemId1, 2, …
should be split out into relational tables.

Second Normal Form (2NF): No partial dependencies on a concatenated key

This is a complex way of saying that if a column isn’t intrinsically related to the entire primary key, then you should break out the primary key into different tables.

Example:
OrderId (PK) ItemId (PK) OrderDate
1 100 2009-01-01
1 101 2009-01-01
The primary key is (OrderId, ItemId).
Consider OrderDate. It is conceptually part of an order. An order always occurs at some time. But is an OrderDate related to an Item? Not really.
You may be saying, “but items are part of an order!”, and you would be right. But that’s not what I’m getting at. OrderDate is independent of the item itself.
Look at another way: in the table above the OrderDate will always be the same for a given OrderId regardless of the value of the ItemId column. This means data duplication, which is denormalization.
Here’s how we correct the problem:
Orders

OrderId (PK) OrderDate
1 2009-01-01
Order_Items

OrderId (PK) ItemId (PK)
1 100
1 101
Here is an excellent line from the article, “All we are trying to establish here is whether a particular order on a particular date relies on a particular item.”

Third Normal Form (3NF): No dependencies on non-key attributes

2NF covers the case of multi-column primary keys. 3NF is meant to cover single column keys. Simply stated, pull out columns that don’t directly relate to the subject of the row (the primary key), and put them in their own table.
Example:
Orders


OrderId (PK) OrderDate CustomerName CustomerCity
1 2009-01-01 John Smith Chicago
Customer information could be the subject of its own table. Pull out customer name and other customer fields into another table, and then put a Customer foreign key into Orders.
Wikipedia has a great quote from Bill Kent: “every non-key attribute ‘must provide a fact about the key, the whole key, and nothing but the key’.”

database normalization

database normalization -1

What is Normalization ? Why should we use it?

Normalization is a database design technique which organizes tables in a manner that reduces redundancy and dependency of data. It divides larger tables to smaller tables and link them using relationships.
The inventor of the relational model Edgar Codd proposed the theory of normalization with the introduction of FirstNormal Form and he continued to extend theory with Second and Third Normal Form. Later he joined with Raymond F. Boyce to develop the theory of Boyce-Codd Normal Form.
Normalization is the process where a database is designed in a way that removes redundancies, and increases the clarity in organizing data in a database.
In easy English, it means take similar stuff out of a collection of data and place them into tables. Keep doing this for each new table recursively and you'll have a Normalized database. From this resultant database you should be able to recreate the data into it's original state if there is a need to do so.
The important thing here is to know when to Normalize and when to be practical. That will come with experience. For now, read on...
Normalization of a database helps in modifying the design at later times and helps in being prepared if a change is required in the database design. Normalization raises the efficiency of the datatabase in terms of management, data storage and scalability.
Now Normalization of a Database is achieved by following a set of rules called 'forms' in creating the database.

 These rules are 5 in number (with one extra one stuck in-between 3&4) and they are:

1st Normal Form or 1NF:

Each Column Type is Unique.

2nd Normal Form or 2NF:

The entity under consideration should already be in the 1NF and all attributes within the entity should depend solely on the entity's unique identifier.

3rd Normal Form or 3NF:

The entity should already be in the 2NF and no column entry should be dependent on any other entry (value) other than the key for the table.
If such an entity exists, move it outside into a new table.
Now if these 3NF are achieved, the database is considered normalized. But there are three more 'extended' NF for the elitist.
These are:

BCNF (Boyce & Codd):

The database should be in 3NF and all tables can have only one primary key.

4NF:

Tables cannot have multi-valued dependencies on a Primary Key.

5NF:

There should be no cyclic dependencies in a composite key.
Well this is a highly simplified explanation for Database Normalization. One can study this process extensively though. After working with databases for some time you'll automatically create Normalized databases. As, it's logical and practical.

Click Here : -  Database Normalization With Example

Wednesday 13 March 2013

difference-between-java-script-and-jquery

difference-between java script and jquery
Categories - Jquery Basic
 

jquery in asp.net

jquery in asp.net

What is jQuery?

jQuery is a fast, lightweight JavaScript library that is CSS3 compliant and supports many browsers. The jQuery framework is extensible and very nicely handles DOM manipulations, CSS, AJAX, Events and Animations.

What is the difference between JavaScript and jQuery?

JavaScript is a language whereas jQuery is a library written using JavaScript. More Difference Click Here 

Advantages of using JQuery in web application?

1. It Improve the performance of the web application
2. It is light weight
3. Its language independent - It can be use with many different language, eg: Asp.Net, PHP, HTML, JSP,etc
4. It is browser compatible - Runs in most browser.
5. It is easy to learn - it uses javascript syntax.
6. You can do complex UI functionality with few lines of code.
7. You can implement ajax within your web application.  It can be used to avoid round trip (avoid page post back) yet able to perform database operation.
8. It is open source library, which is also officially integrated in visual studio 2010.
9. You will find lot of JQuery functionality shared other developers, which helps you to avoid in reinventing the wheel.
And much more...

1) How to use JQuery in Asp.net Web Application? 

Creating your first Hello World application in JQuery

Step 1: Open Visual Studio

Step 2: Create a new web application project (Web site...)

Step 3: Open master page of your web application.
Put this line of code, above </head>
<script type="text/javascript" language="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

Above line adds JQuery library reference to your web application, in simple terms with above line you web application understands JQuery syntax and work accordingly.

Step 4: Put following line of code in you content page inside <asp:Content>.  Below line will display "Hello World" alert when page loads.
<script language="javascript" type="text/javascript">
        $(document).ready(function () {
            alert("Hello World");             
        });
    </script>

Understanding  $(document).ready(function ()

If you want an JQuery event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded.

$(document) - means page on which JQuery code lies.
.ready() - means page is loaded and your JQuery code is ready to be executed.

And for that reason you may find that most of JQuery code lies within

<script language="javascript" type="text/javascript">
        $(document).ready(function () {

         JQUERY CODE GOES HERE

});
</script>



So finally you will be able to display alert on page load in your asp.net web application with JQuery.



May be this question might comes to your mind, I can show "Hello World" alert without using JQuery then what is fun of using JQuery?
Well its too early to judge, since this article is for beginners i have explained with simple example there is lot more coming.

Where can I download jQuery?

You can Directlly download the jquery from this link
If you are using visual stdio 2010 then you will not required fro download any type of  jquery
because in scripts folder all jquery is available  .
Most Probably we use only  jquery-1.4.1.js  this jquery library

2)  Simple Example for using a jquery


Open Visual Studio 2010 > File > New > Website > Choose ‘ASP.NET website ' from the templates > Choose your language (C# or VB) > Enter the location > Ok.
if scripts folder not available then perform this task
In the Solution Explorer,right click your project > New Folder > rename the folder as ‘Scripts’. Right click the Scripts folder > Add Existing Item > Browse to the path where you downloaded the jQuery library (jquery-1.4.1.js) and the intellisense documentation (jquery-1.4.1-vsdoc.js) > Select the files and click Add. The structure will look similar to the following:

Now drag and drop the jquery file from the Solution Explorer on to your page to create a reference as shown below
Note: Since you have applied the hotfix, you do not have to manually add a reference to the jquery-1.4.1.js file in your page. Once the reference to the runtime library has been added, Visual Studio automatically searches for the ‘vsdoc’ file and loads it. You just need to keep both the runtime library and the documentation file next to each other.
To test intellisense, add a < script > block and key in ‘$(‘. You will get an intellisense similar to the one shown below:

examples

Example 1 – Display an alert on asp:Button click using jQuery Add a Button element to the page as shown below:
 <asp:Button ID="Button1" runat="server" Text="Button" />
Drag and drop a button control on the form
Now in order to tell the browser to perform some action using jQuery as soon as the document is ready or loaded, use this block:
<script type="text/javascript">
        $(document).ready(function() {
        // add code here
        });
    </script> 
Add your code in the function block
    <script type="text/javascript">
        $(document).ready(function() {
        $("#Button1").click(function() {
            alert("Hello How Are You");
        });
        });
    </script>
Ouptup 

jquery basics

jquery basics
Abstract: This article is a guide for getting started with jQuery using ASP.NET and Visual Studio 2008/2010. The article also shows you how to use Visual Studio intellisense feature to develop jQuery and ASP.NET applications. 
Jquery is an awesome javascipt library, it’s help you for developing dazing web projects.
In this tutorial I want to discuss very basic level jquery and working with Click() event.

How to add jQuery to your website

Installing
You can download jquery.js file form jquery.com.

<script type="text/javascript" src="jquery.js"></script>
OR
Recommended
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js
"></script>

Jquery Code
Generally used script run this when the HTML is all ready.  Live Demo
<script type="text/javascript">
$(document).ready(function()
{
alert('Welcome dotnetnukes Jquery Basic Series');
});
</script>

Similar as previous script. Take a look at Live Demo
<script type="text/javascript">
$(function()
{
alert('Welcome dotnetnukes Jquery Basic Series');
});
</script>

Run this when the whole page has been downloaded. Take a look at Live Demo
<script type="text/javascript">
$(window).load(function()
{
alert('Loaded Whole Page including images)');
});
</script>



jQuery Stucture
Here $ = jquery, selector is a DOM element and function execute a jquery fuction.
$(selector).function(parameters);

DOM - Document Object Model Wiki

Selectors

-> Select DOM elements eg: $('h1') ,$('div'), $('li')..
-> Select ID : $('#id_name')
-> Select Class : $('.class_name')

Working with Click() Event
Structure $(selector).click(). Take a look at Live Demo
<script type="text/javascript">
$(function()
{

$('#button_action').click(function()
{
alert('Hey Button');
});

$('.link_action').click(function()
{
alert('Hey Link');
});

});
</script>
<body>
<include type='button' value='BUTTON' id='button_action'/>
<a href='#' class='link_action'>LINK</a>
</body>

Hide and Show With Click Event
Hiding and Showing the div tag. Take a look at Live Demo
<script type="text/javascript">
$(function()
{

$('.hide_box').click(function()
{
$('#box').hide();
});

$('.show_box').click(function()
{
$('#box').show();
});

});
</script>
<body>
<a href="#" class="hide_box">HIDE</a>
<a href="#" class="show_box">SHOW</a>
<div id="box"></div>
</body>

Tuesday 12 March 2013

JavaScript Remove Duplicate Values from Array String

JavaScript Remove Duplicate Values from Array String

JavaScript Remove Duplicate Values from Array String

Introduction
Here I will explain how to use JavaScript to remove duplicate values from array or remove duplicate values/elements from string array using JavaScript
Description:
In previous article I explained JavaScript, jQuery, SQL, asp.net etc. Now I will explain how to remove duplicate values/elements from string array using JavaScript.

To remove duplicate values/elements from string array using JavaScript we need to write the code like as shown below
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Remove duplicates from an array using JavaScript </title>
<script type="text/javascript">
function RemoveList() {
var sampleArr = new Array(1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4); //Sample array
uniqueArr(sampleArr);
}
//Adds new uniqueArr values to temp array
function uniqueArr(arr) {
arr1 = new Array();
for (i = 0; i < arr.length; i++) {
if (!checkstatus(arr1, arr[i])) {
arr1.length += 1;
arr1[arr1.length - 1] = arr[i];
}
}
alert(arr1);
}
// Check if it contains unique or duplicate record
function checkstatus(arr, e) {
for (j = 0; j < arr.length; j++) if (arr[j] == e) return true;
return false;
}
</script>
</head>
<body>
<div>
<input type="button" value="Remove Duplicates" onclick="RemoveList()" />
</div>
</body>
</html>
Live Demo
For live demo click on below button it will return only unique values from this string (1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4) values


How to Get Screen Resolution of User or Client Machine using java script

Introduction
Here I will explain how to Get Monitor screen resolution using JavaScript or Get screen resolution of user in JavaScript.
Description:
To get user screen resolution we need to write the code like as shown below
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Screen Resolution using JavaScript</title>
<script type="text/javascript" language="javascript">
function GetResolution(){
document.getElementById("txtWidth").value = screen.width;
document.getElementById("txtHight").value = screen.height;
}
</script>
</head>
<body onload="GetResolution();">
<table>
<tr><td align="center" colspan="2">
<b><span style="color: #990000;">Your Screen Resolution </span></b></td></tr>
<tr>
<td>Width :</td>
<td valign="middle"><input type="text" size="5" name="txtWidth" id="txtWidth">px</td>
</tr>
<tr>
<td>Height :</td>
<td valign="middle"><input type="text" size="5" name="txtHight" id="txtHight">px</td>
</tr>
</table>
</body>
</html>
Live Demo
For live demo check below of your screen resolution details
Your Screen Resolution
Width : px
Height : px
How to Get Screen Resolution of User or Client Machine
 

..




New Updates

Related Posts Plugin for WordPress, Blogger...

Related Result