Pages

Ads 468x60px

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

.

Friday 15 March 2013

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

Monday 11 March 2013

Check Internet Connection in Asp.net using C#, VB.NET

Check Internet Connection in Asp.net using C#, VB.NET 
Introduction

Here I will explain how to check internet connectivity of system in 
asp.net and C#.net VB.NET.
Description
    In my previous article i have explained
jQuery Get Number of Facebook likes, Shares, Comments using asp.net.  Now I will explain how to check internet connectivity of system in asp.net using C# and VB.NET.

We can check internet connectivity of system by downloading data of one website from server for that write code like as shown below
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Check Internet Connection Availability using Asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button runat="server" ID="btnCheck" Text="Check Internet Connectivity" OnClick="btnCheck_Click" />
<asp:Label runat="server" ID="lbltxt" />
</div>
</form>
</body>
</html>
Now in code behind add the following namespaces
C# Code
using System;
using System.Net;
After that write the following code in code behind
protected void btnCheck_Click(object sender, EventArgs e)
{
WebClient client = new WebClient();
byte[] datasize = null;
try
{
datasize = client.DownloadData("http://www.google.com");
}
catch (Exception ex)
{
}
if (datasize != null && datasize.Length > 0)
lbltxt.Text = "Internet Connection Available.";
else
lbltxt.Text = "Internet Connection Not Available.";
}
VB.NET Code

Imports System.Net
Partial Class VBCode
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub btnCheck_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim client As New WebClient()
Dim datasize As Byte() = Nothing
Try
datasize = client.DownloadData("http://www.google.com")
Catch ex As Exception
End Try
If datasize IsNot Nothing AndAlso datasize.Length > 0 Then
lbltxt.Text = "Internet Connection Available."
Else
lbltxt.Text = "Internet Connection Not Available."
End If
End Sub
End Class
Demo

 

..




New Updates

Related Posts Plugin for WordPress, Blogger...

Related Result