Pages

Ads 468x60px

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

.

Tuesday, 30 April 2013

database-normalization

database-normalization

First Normal Form

  • Eliminate repeating groups in individual tables.
  • Create a separate table for each set of related data.
  • Identify each set of related data with a primary key.
Do not use multiple fields in a single table to store similar data. For example, to track an inventory item that may come from two possible sources, an inventory record may contain fields for Vendor Code 1 and Vendor Code 2.

What happens when you add a third vendor? Adding a field is not the answer; it requires program and table modifications and does not smoothly accommodate a dynamic number of vendors. Instead, place all vendor information in a separate table called Vendors, then link inventory to vendors with an item number key, or vendors to inventory with a vendor code key.

Second Normal Form

  • Create separate tables for sets of values that apply to multiple records.
  • Relate these tables with a foreign key.
Records should not depend on anything other than a table's primary key (a compound key, if necessary). For example, consider a customer's address in an accounting system. The address is needed by the Customers table, but also by the Orders, Shipping, Invoices, Accounts Receivable, and Collections tables. Instead of storing the customer's address as a separate entry in each of these tables, store it in one place, either in the Customers table or in a separate Addresses table.

Third Normal Form

  • Eliminate fields that do not depend on the key.
Values in a record that are not part of that record's key do not belong in the table. In general, any time the contents of a group of fields may apply to more than a single record in the table, consider placing those fields in a separate table.

For example, in an Employee Recruitment table, a candidate's university name and address may be included. But you need a complete list of universities for group mailings. If university information is stored in the Candidates table, there is no way to list universities with no current candidates. Create a separate Universities table and link it to the Candidates table with a university code key.

EXCEPTION: Adhering to the third normal form, while theoretically desirable, is not always practical. If you have a Customers table and you want to eliminate all possible interfield dependencies, you must create separate tables for cities, ZIP codes, sales representatives, customer classes, and any other factor that may be duplicated in multiple records. In theory, normalization is worth pursing. However, many small tables may degrade performance or exceed open file and memory capacities.

It may be more feasible to apply third normal form only to data that changes frequently. If some dependent fields remain, design your application to require the user to verify all related fields when any one is changed.

Other Normalization Forms

Fourth normal form, also called Boyce Codd Normal Form (BCNF), and fifth normal form do exist, but are rarely considered in practical design. Disregarding these rules may result in less than perfect database design, but should not affect functionality.

Normalizing an Example Table

These steps demonstrate the process of normalizing a fictitious student table.
  1. Unnormalized table:

    Student#AdvisorAdv-RoomClass1Class2Class3
    1022Jones412101-07143-01159-02
    4123Smith216201-01211-02214-01
  2. First Normal Form: No Repeating Groups

    Tables should have only two dimensions. Since one student has several classes, these classes should be listed in a separate table. Fields Class1, Class2, and Class3 in the above records are indications of design trouble.

    Spreadsheets often use the third dimension, but tables should not. Another way to look at this problem is with a one-to-many relationship, do not put the one side and the many side in the same table. Instead, create another table in first normal form by eliminating the repeating group (Class#), as shown below:

    Student#AdvisorAdv-RoomClass#
    1022Jones412101-07
    1022Jones412143-01
    1022Jones412159-02
    4123Smith216201-01
    4123Smith216211-02
    4123Smith216214-01         
  3. Second Normal Form: Eliminate Redundant Data
    Note the multiple Class# values for each Student# value in the above table. Class# is not functionally dependent on Student# (primary key), so this relationship is not in second normal form.

    The following two tables demonstrate second normal form:

    Students:

    Student#AdvisorAdv-Room
    1022Jones412
    4123Smith216


    Registration:

    Student#Class#
    1022101-07
    1022143-01
    1022159-02
    4123201-01
    4123211-02
    4123214-01
  4. Third Normal Form: Eliminate Data Not Dependent On Key

    In the last example, Adv-Room (the advisor's office number) is functionally dependent on the Advisor attribute. The solution is to move that attribute from the Students table to the Faculty table, as shown below:

    Students:

    Student#Advisor
    1022Jones
    4123Smith


    Faculty:

    NameRoomDept
    Jones41242
    Smith21642

Monday, 29 April 2013

change text box border color css using jquery asp.net

change text box border color css using jquery asp.net
Introduction : -
Here i will explain how i can change the boder color of textbox after insert the number using Jquery in Asp.Net   In My Previous Article I have Provide  jQuery Restrict to Allow Only Numbers in Textbox in Asp.net .

Description : -
In previous posts I explained  I have Explain create simple drop down menu using jquery ,Simple Menu using Jquery step by step  Now   I will expplain how to allow only numbers or numeric characters in textbox using Jquery  in Asp.net .

Jquery Scripts As Shown Below for Change the textbox Border Color in asp.net

Note :- I am  using visual stdio 2010 show i  include the jquey in my page form the scripts folder




<head runat="server">
    <title>Change textbox color on insert the any alfa numeric values</title>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>

<!--change the border color color of textbox-->
    <script type="text/javascript" language="javascript">
        debugger;
        $(document).ready(function () {
            $(".txt1").keypress(function () {
                var str = /^[0-9a-zA-Z]+$/;
                var value = $(this).val();
                if (!str.test(value)) {
                    $(".txt1").css({ borderColor: 'Red' });
                }
                else {
                    $(".txt1").css({ borderColor: 'Green', BorderWidth: '3px' });
                }

            }).keypress();
        });
</script>

<script type="text/javascript">

    $(document).ready(function () {

        $(".txt2").keypress(function () {

            var str2 = /^[0-9a-zA-Z]+$/;
            var value = $(this).val();
            if (!str2.test(value)) {
                $(".txt2").css({ borderColor: 'red' });
            }
            else {
                $(".txt2").css({ borderColor: 'Green', BorderWidth: '2px' });
            }
        });
    });

</script>

</head>

Asp.net Text Box Controll On the Form As shown Below






<body>
<center>
    <form id="form1" runat="server">
    <div>
        Name&nbsp;&nbsp; :&nbsp; <asp:TextBox ID="txt2" runat="server" BorderWidth="2px" class="txt2"></asp:TextBox><br/><br/>
    Password :&nbsp; <asp:textbox id="txt1" runat="server" borderwidth="1px" class="txt1"></asp:textbox>
    </div>
    </form>
    </center>
</body>


 Output Windows as shown below



Download sample code attached



Implicit conversion from data type varchar to varbinary is not allowed

Implicit conversion from data type varchar to varbinary is not allowed [Error Solution]
Error :-Implicit conversion from data type varchar to varbinary is not allowed

Solution :- This Problem Occur when we define the wrong data type declaration for create the table 
Example as Shown Below




CREATE TABLE [dbo].[issue_tab](
 [id] [int] IDENTITY(1,1) NOT NULL,
 [name] [varchar](255) NULL,
 [party] [varchar](255) NULL,
 [address] [text] NULL,
 [related_person] [varchar](255) NULL,
 [type_selection] [varchar](255) NULL,
 [contactno] [VARBINARY(MAX)](10) NULL,
 CONSTRAINT [PK_issue_tab] PRIMARY KEY CLUSTERED 
(
 [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF
, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON,
 ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

In this Above table Lock at the highlight contactno coloumn .The datatype is[VARBINARY(MAX)](10) NULL show we get the error .

Result : - So Change the Data Type Like Varchar and According to You Want to Enter From the Form



CREATE TABLE [dbo].[issue_tab](
 [id] [int] IDENTITY(1,1) NOT NULL,
 [name] [varchar](255) NULL,
 [party] [varchar](255) NULL,
 [address] [text] NULL,
 [related_person] [varchar](255) NULL,
 [type_selection] [varchar](255) NULL,
 [contactno] [varchar]](255) NULL,
 CONSTRAINT [PK_issue_tab] PRIMARY KEY CLUSTERED 
(
 [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF
, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON,
 ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
---------------------------------------------------------------------------------------------------------

jQuery Restrict to Allow Only Numbers in Textbox in Asp.net

create simple drop down menu using jquery
Introduction : -
Here I will explain how to allow only numbers or numeric characters in textbox using JQuery in asp.net.with error message 

Description :- 
In previous posts I explained  I have Explain create simple drop down menu using jquery ,Simple Menu using Jquery step by step  Now   I will expplain how to allow only numbers or numeric characters in textbox using JQuery in asp.net.

To restrict user to enter only number in textbox we write the following code as shown below

Jquery code as shown below

 Code is Here




<head runat="server">
    <title>jquery text box valiation only enter the number</title>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
    //called when key is pressed in textbox
            $("#quantity").keypress(function (e) {
                //if the letter is not digit then display error and don't type anything
                if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
                    //display error message
                    $("#errmsg").html("Digits Only").show().fadeOut("slow");
                    return false;
                }
            });
        });
 
    </script>
    <style type="text/css">
    #errmsg
    {
        color:Red;
    </style>

  
</head>

asp.net  form code here
 Code is Here




<body>
    <form id="form1" runat="server">
    <div>
   Number : <input type="text" name="quantity" id="quantity" />&nbsp;<span id="errmsg"></span><br /><br/>
 
    </div>
    </form>
</body>

After Write Code The Page Is Shown Below



Download sample code attached






Simple Menu using Jquery Beginners Tutorial , create simple drop down menu using jquery

Friday, 26 April 2013

create simple drop down menu using jquery

create simple drop down menu using jquery
Introduction : -

While creating menus, the most preferred method is to use some sort of lists which will ease in standardization of the thing. This way styling with CSS become more easier and powerful. For a complete reference of how lists work check this link for reference.

You can see a demo of resultant menu here


Thursday, 25 April 2013

Introduction to WCF

onclick checkbox select data from gridview asp.net
Introduction :-

Windows Communication Foundation (Code named Indigo) is a programming platform and runtime system for building, configuring and deploying network-distributed services. It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF. It is unified programming model provided in .Net Framework 3.0. WCF is a combined features of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication.
Below figures shows the different technology combined to form WCF.





Advantage

  1. WCF is interoperable with other services when compared to .Net Remoting,where the client and service have to be .Net.
  2. WCF services provide better reliability and security in compared to ASMX web services.
  3. In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small changes in the configuration will make your requirements.
  4. WCF has integrated logging mechanism, changing the configuration file settings will provide this functionality. In other technology developer has to write the code.

Disadvantage

Making right design for your requirement is little bit difficult. I will try to help you on solving these difficulties in the following article.

onclick checkbox select data from gridview asp.net

onclick checkbox select data from gridview asp.net
 Introduction : -

In this Tutorial when user select the one or multipal  checkbox  from the gridview and show the values on the form.

Description : -
 
In my Previous article i have provided the asp.net interview questions with answers for 2 years experience  Ajax AsyncFileUpload control example in asp.net to upload files to server   jquery form validation in asp.net  I have Provide the More Difference b/w Differences Between WCF and ASP.NET Web Services   and also provide the  create restful wcf service api using post step by step
To get checkbox selected row values from gridview we need to write the code like this


C# Code

foreach(GridViewRow  gvrow in gvDetails.Rows)
{
CheckBox chk = (CheckBox)gvrow.FindControl("chkSelect");
if (chk != null & chk.Checked)
{
str += gvDetails.DataKeys[gvrow.RowIndex].Value.ToString() + ',';
strname += gvrow.Cells[2].Text+',';
}
}
If you want to see complete example we need to write the following code in aspx page
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript" language="javascript">

        function ConfirmOnDelete(item) {

            if (confirm("Would you like to delete selected item(s)?") == true)

                return true;

            else

                return false;

        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:GridView ID="gvDetails" DataKeyNames="UserId" AutoGenerateColumns="False"
            CellPadding="4" runat="server" ForeColor="#333333" GridLines="None">
          <AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="UserId" DataField="UserId" />
<asp:BoundField HeaderText="UserName" DataField="UserName" />
<asp:BoundField HeaderText="Education" DataField="Education" />
<asp:BoundField HeaderText="Location" DataField="Location" />
</Columns>
          <EditRowStyle BackColor="#7C6F57" />
          <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="true" ForeColor="White" />
          <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
          <RowStyle BackColor="#E3EAEB" />
          <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
          <SortedAscendingCellStyle BackColor="#F8FAFA" />
          <SortedAscendingHeaderStyle BackColor="#246B61" />
          <SortedDescendingCellStyle BackColor="#D4DFE1" />
          <SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
<asp:Button ID="btnProcess" Text="Get Selected Records" runat="server"
Font-Bold="true" onclick="btnProcess_Click" /><br />
<asp:Label ID="lblmsg" runat="server" />
    </div>
    </form>
</body>
</html>

Now in code behind add the following namespaces

C# Code

using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
Now add below code in code behind

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGridviewData();
        }
  
    }

     protected void BindGridviewData()
{
DataTable dt = new DataTable();
dt.Columns.Add("UserId", typeof(Int32));
dt.Columns.Add("UserName", typeof(string));
dt.Columns.Add("Education", typeof(string));
dt.Columns.Add("Location", typeof(string));
DataRow dtrow = dt.NewRow();    // Create New Row
dtrow["UserId"] = 1;            //Bind Data to Columns
dtrow["UserName"] = "chitranjan";
dtrow["Education"] = "M.C.A";
dtrow["Location"] = "Indore";
dt.Rows.Add(dtrow);
dtrow = dt.NewRow();               // Create New Row
dtrow["UserId"] = 2;               //Bind Data to Columns
dtrow["UserName"] = "Aman";
dtrow["Education"] = "B.E";
dtrow["Location"] = "Pune";
dt.Rows.Add(dtrow);
dtrow = dt.NewRow();              // Create New Row
dtrow["UserId"] = 3;              //Bind Data to Columns
dtrow["UserName"] = "Rahul";
dtrow["Education"] = "B.Tech";
dtrow["Location"] = "Bombai";
dt.Rows.Add(dtrow);
dtrow = dt.NewRow();              // Create New Row
dtrow["UserId"] = 4;              //Bind Data to Columns
dtrow["UserName"] = "Amar";
dtrow["Education"] = "B.E";
dtrow["Location"] = "Bhopal";
dt.Rows.Add(dtrow);

gvDetails.DataSource = dt;
gvDetails.DataBind();
}


     protected void btnProcess_Click(object sender, EventArgs e)
     {
         string str = string.Empty;
         string strname = string.Empty;
         foreach (GridViewRow gvrow in gvDetails.Rows)
         {
             CheckBox chk = (CheckBox)gvrow.FindControl("chkSelect");
             if (chk != null & chk.Checked)
             {
                 str += gvDetails.DataKeys[gvrow.RowIndex].Value.ToString() + ',';
                 strname += gvrow.Cells[2].Text + ',';
             }
         }
         str = str.Trim(",".ToCharArray());
         strname = strname.Trim(",".ToCharArray());
         lblmsg.Text = "Selected UserIds: <b>" + str + "</b><br/>" + "Selected UserNames: <b>" + strname + "</b>";
     }
Screen Short as shown below

After Select Check Box Show The Data


Download sample code attached

Tuesday, 23 April 2013

mongodb upload image using php

mongodb upload image using php
Categories :- What is Mongodb  Install Mongo on CentOS,Fedora, Ubuntu & Debian


Introduction : - In My privous article i have explained  What is Mongodb
GridFS is a specification for storing large files in MongoDB. In this post I will explain how you can easily upload a file to GridFS and then retrieve it from the database to serve it to the browser

The name of the uploaded file to store. This should correspond to the file field's name attribute in the HTML form
<html>
<body>
<!--The name of the uploaded file to store. This should correspond to the file field's name attribute in the HTML form. -->
<form method="POST" enctype="multipart/form-data">
    <label for="username">Username:</label>
    <input type="text" name="username" id="username" />
    <label for="pic">Please upload a profile picture:</label>
    <input type="file" name="pic" id="pic" />
    <input type="submit" />
</form>

</html></body>

If you wanted to store the uploaded image in MongoDB, you could do the following in the script handling the form submission:

<?php
error_reporting(0); //// Turn off all error reporting
//If you wanted to store the uploaded image in MongoDB, you could do the following in the script handling the form submission:
$m = new MongoClient();
$gridfs = $m->selectDB('test')->getGridFS();

$gridfs->storeUpload('pic', array('username' => $_POST['username']));
echo 'File Uploaded Successfully';

?>

Complete Code As Show Below

<!-- image and any file  uploaded  in mongodb -->
<html>
<body>
<!--The name of the uploaded file to store. This should correspond to the file field's name attribute in the HTML form. -->
<form method="POST" enctype="multipart/form-data">
    <label for="username">Username:</label>
    <input type="text" name="username" id="username" />
    <label for="pic">Please upload a profile picture:</label>
    <input type="file" name="pic" id="pic" />
    <input type="submit" />
</form>

</html></body>

<?php
error_reporting(0); //// Turn off all error reporting
//If you wanted to store the uploaded image in MongoDB, you could do the following in the script handling the form submission:
$m = new MongoClient();
$gridfs = $m->selectDB('test')->getGridFS();

$gridfs->storeUpload('pic', array('username' => $_POST['username']));
echo 'File Uploaded Successfully';

?>

Running output Image Screen Short As shown Below
1-> Run the Fie then

2-> when insert the Name and Browse the Image Screen Short As Show Below

3-> When Click on Submit  Query Button Get the Message (File Uploaded Successfully)


 4-> Check the Out In Database Image is Save or not open the genghis phpadmin then output as shown below




Download sample code attached



Monday, 22 April 2013

Differences Between WCF and ASP.NET Web Services

Differences Between WCF and ASP.NET Web Services
Categories :-    Introduction to WCF
 




Web Services WCF Services
Web services were developed for building applications that send and receive messages by using the Simple Object Access Protocol (SOAP) over HTTP. The structure of the messages can be defined using an XML Schema, and a tool is provided to facilitate serializing the messages to and from .NET Framework objects. The technology can automatically generate metadata to describe Web services in the Web Services Description Language (WSDL) WCF services were developed for building applications to send and receive messing by using many formats and conveyed by using any transport protocol. Simple Object Access Protocol (SOAP) is used by default format.The structure of the messages can be defined using an XML Schema, and there are various options for serializing the messages to and from .NET Framework objects. WCF can automatically generate metadata to describe applications built using the technology in WSDL, and it also provides a tool for generating clients for those applications from the WSDL.

Support for sending messages using not only HTTP, but also TCP and other network protocols. The ability to switch message protocols with minimal effort. Support for hosting services on hosts other than a Web server. Built-in support for the latest Web services standards (SOAP 1.2 and WS-*) and the ability to easily support new ones. Support for security, transactions and reliability. Support for sending messages using formats other than SOAP.
XmlSerializer DataContractSerializer
ASP.NET relies on the XmlSerializer to translate data represented by .NET Framework types to XML for transmission to or from a service and to translate data received as XML into .NET Framework objects. Defining the complex data types that an ASP.NET service is to use requires the definition of .NET Framework classes that the XmlSerializer can serialize to and from XML. The DataContractAttribute signifies that zero or more of a type’s fields or properties are to be serialized, while the DataMemberAttribute indicates that a particular field or property is to be serialized. The DataContractAttribute can be applied to a class or structure. The DataMemberAttribute can be applied to a field or a property, and the fields and properties to which the attribute is applied can be either public or private. Instances of types that have the DataContractAttribute applied to them are referred to as data contracts in WCF. They are serialized into XML using DataContractSerializer.
The XmlSerializer and the attributes of the System.Xml.Serialization namespace are designed to allow you to map .NET Framework types to any valid type defined in XML Schema, and so they provide for very precise control over how a type is represented in XML. The DataContractSerializer, DataContractAttribute and DataMemberAttribute provide very little control over how a type is represented in XML. You can only specify the namespaces and names used to represent the type and its fields or properties in the XML, and the sequence in which the fields and properties appear in the XML. Everything else about the structure of the XML used to represent the .NET type is determined by the DataContractSerializer. By not permitting much control over how a type is to be represented in XML, the serialization process becomes highly predictable for the DataContractSerializer, and, thereby, easier to optimize.
Lesser performance compared with WCF DataContractSerializer. A practical benefit of the design of the DataContractSerializer is better performance, approximately ten percent better performance.
The attributes for use with the XmlSerializer do not indicate which fields or properties of the type are serialized into XML. DataMemberAttribute for use with the DataContractSerializer shows explicitly which fields or properties are serialized. Therefore, data contracts are explicit contracts about the structure of the data that an application is to send and receive.
The XmlSerializer can only translate the public members of a .NET object into XML. The DataContractSerializer can translate the members of objects into XML regardless of the access modifiers of those members.
Instances of collection classes can be serialized into XML only if the classes implement either the IEnumerable or ICollection interface. The DataContractSerializer is much more likely to be able to serialize the instances of any pre-existing .NET type into XML without having to either modify the definition of the type or develop a wrapper for it.
Classes that implement the IDictionary interface, such as Hashtable, cannot be serialized into XML. It can translate into XML types like Hashtable that implement the IDictionary interface.
XmlSerializer does not support versioning. The DataContractSerializer incorporates some support for versioning.
XmlSerializer serializes a type by default is semantically identical to the XML. DataContractSerializer serializes a type, provided the namespace for the XML is explicitly defined.

What is REST & RESTful?

Representational State Transfer (REST) is introduced by Roy Fielding on 2000; it is an architectural style of large-scale networked software that takes advantage of the technologies and protocols of the World Wide Web. REST illustrate how concentrated data objects, or resources, can be defined and addressed, stressing the easy exchange of information and scalability.
 EST architectural style is known as RESTFul Services.

WCF Services

RESTFul Services

Endpoints have to create for each network protocol It can be connect over "Web" with HTTP request/response messages.
It works based on the Remote Procedural Call (RPC) It is working with HTTP's uniform interface
Service Reference has to add in the client applications No need to add the service reference in the client applications

Difference between WCF and Web service

Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service, following table provides detailed difference between them.
Features Web Service WCF
Hosting It can be hosted in IIS It can be hosted in IIS, windows activation service, Self-hosting, Windows service
Programming [WebService] attribute has to be added to the class [ServiceContraact] attribute has to be added to the class
Model [WebMethod] attribute represents the method exposed to client [OperationContract] attribute represents the method exposed to client
Operation One-way, Request- Response are the different operations supported in web service One-Way, Request-Response, Duplex are different type of operations supported in WCF
XML System.Xml.serialization name space is used for serialization System.Runtime.Serialization namespace is used for serialization
Encoding XML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom XML 1.0, MTOM, Binary, Custom
Transports Can be accessed through HTTP, TCP, Custom Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom
Protocols Security Security, Reliable messaging, Transactions

Sunday, 21 April 2013

how to create virtual directory in iis

how to create virtual directory in iis

To create a virtual directory by using IIS Manager

  1. In IIS Manager, expand the local computer and the Sites folder, and then find the Web site that you want to add a virtual directory for. Use the following steps:

    • For , right-click the site or folder where you want to create the virtual directory, and then click Add Virtual Directory.
    • For Windows Server 2008, right-click the site or folder where you want to create the virtual directory, click Manage Web Site, and then click Add Virtual Directory.
  2. In the Add Virtual Directory dialog box, specify the following information:

    • Alias. Type a name for the virtual directory. Choose a short name that is easy to type, because the user types this name to access the Web site.
    • Physical Path. Type or browse to the physical directory that contains the virtual directory. You can select an existing folder or create a new one to contain the content for the virtual directory.
  3. To provide credentials to connect to a UNC path, click the Connect as button.
  4. Click OK.

Saturday, 20 April 2013

asp.net interview questions with answers for 2 years experience

asp.net interview questions with answers for 2 years experience
1 :- If I have more than one version of one assemblies, then how will I use old version (how/where to specify version number?) in my application?

Ans.The version number is stored in the following format: …. The assembly manifest can then contain a reference to which version number we want to use.

2  :-  How do you create threading in.NET? What is the namespace for that?
Ans.
System.Threading;

//create new thread using the thread class’s constructor

Thread myThread = new Thread(new ThreadStart (someFunction));

3 : - What do you mean by Serialize and MarshalByRef?
Ans.
Serialization is the act of saving the state of an object so that it can be recreated (i.e deserialized) at a later date.
The MarshalByRef class is part of the System.Runtime.Remoting namespace and enables us to access and use objects that reside in different application
domains. It is the base class for objects that need to communicate across application domains. MarshalByRef objects are accessed directly within their own
application domain by using a proxy to communicate. With MarshalByValue the a copy of the entire object is passed across the application domain

  4 : - What is the difference between Array and LinkedList?
Ans.An array is a collection of the same type. The size of the array is fixed in its declaration.
A linked list is similar to an array but it doesn’t have a limited size.

8 :-  What is Asynchronous call and how it can be implemented using delegates?
Ans.
A synchronous call will wait for a method to complete before program flow is resumed. With an asynchronous call the program flow continues whilst the method executes.

//create object
SomeFunction objFunc = new SomeFunction();

//create delegate
SomeDelegate objDel = new SomeDelegate(objFunc.FunctionA);

//invoke the method asynchronously (use interface IAsyncResult)
IAsyncResult asynchCall = SomeDelegate.Invoke();

  9 :- How to create events for a control? What is custom events? How to create it?
Ans.
An event is a mechanism used in a class that can be used to provide a notification when something interesting happens. (typical evens in a windows application
include: change text in textbox, double click or click a button, select an item in dropdown box).
A custom event is an event created by the user that other developers can use. For example assuming that we have a CashTransaction class and we have a bank
balance property in that class. We may want to set-up an event that provides a notification when the bank balance drops below a certain amount. In order to
produce an event the process would be roughly as follows:
Create the class for the event derived from EventArgs.
Create a delegate with a return type of void.
Create a class containing the method that will activate the event.
Create a class with methods to handle the event.

  10 : - If you want to write your own dot net language, what steps you will you take care?

Ans.We will need to ensure that the high level code is compiled to MSIL (Microsoft intermediate language) so that it can be interpreted by the CLR.

11 : -  Describe the diffeerence between inline and code behind - which is best in a loosely coupled solution?

Ans.
The term ‘code behind’ refers to application code that is not embedded within the ASPX page and is separated out into a separate file which is then referenced
from the ASPX page. Inline code is the traditional ASP architectural model where business logic code was embedded within the ASP page. Separating the business
logic code from the presentation layer offers several advantages:
1) It allows graphic designers and web developers to work on the presentation layer whilst the application developers concentrate on the business logic.
2) The codebehind file is compiled as a single dll increasing the efficiency of the application,
3) The codebehind model offers a true OO development platform,
4) It speeds up development time as it allows developers to fully maximise the features of the .NET framework such as Cahing, ViewState, Session, Smart Navigation etc.
5) Code is much easier to maintain and susceptible for change.
6) The compiler and VS.NET provides much better support for error checking, intellisense and debugging when using the code behind model.

12 : -  How dot net compiled code will become platform independent?
Ans.
The raison d’etre for .NET was to cater for multiples languages on a single windows platform whereas the aim of Java was to be a single language on multiple
platforms. The only way that .NET can be platform independent is if there is a version of the .NET framework installed on the target machine.

  13 : - Without modifying source code if we compile again, will it be generated MSIL again?

Ans.No.

  14 : - How does you handle this COM components developed in other programming languages in.NET?

Ans.
use TlbImp.exe to import the COM types into your .NET project. If no type library for the COM component then use System.Runtime.InteropServices
use RegAsm.exe to call a .NET developed component in a COM application.

  15 : - How CCW (Com Callable Wrapper) and RCW (Runtime Callable Wrappers) works?

Ans.
CCW: When a COM application calls a NET object the CLR creates the CCW as a proxy since the COM application is unable to directly access the .NET object.
RCW: When a .NET application calls a COM object the CLR creates the RCW as a proxy since the .NET application is unable to directly access the .COM object.

  16 :- What are the new thee features of COM+ services, which are not there in COM (MTS)?

Ans.
Role based security.
Neutral apartment threading.
New environment called context which defines the execution environment

  17 : - What are the differences between COM architecture and.NET architecture?

Ans.
.Net architecture has superseded the old COM architecture providing a flexible rapid application development environment which can be used to create windows,
web and console applications and web services. .NET provides a powerful development environment that can be used to create objects in any .NET compliant language.
.NET addresses the previous problems of dll hell with COM by providing strongly named assemblies and side-by-side execution where two assemblies with the same name can run on the same box.

  18 : - Can we copy a COM dll to GAC folder?

Ans.
No. It only stores .NET assemblies.

  19 : - What is Shared and Repeatable Inheritance?

Ans.
Shared Inheritance-: Shared Inheritance-: ITt is multiple times using same class. The mechanism of deriving a new class from an existing class is called inheritance. Shared inheritance introduces a new opportunity of ambiguity and additional implementation complexity. Assume D inherits from B and C, both of which inherits from A. Here A in shared. Single copy made from both derived classes is called shared inheritance.

 20 : - Can you explain what inheritance is and an example of when you might use it?
 
Ans
.
Inheritance is a fundamental feature of any OO language. It allows us to inherit the members and attributes from a base class to a new derived class. This
leads to increased code reusability and also makes applications easier to develop, maintain and extend as the new derived class can contain new features not
available in the base class whilst at the same time preserving the attributes inherited from the base class.

21 : -  How can you write a class to restrict that only one object of this class can be created (Singleton class)?

Ans.

Use the singleton design pattern.

 public sealed class Singleton  
 {  
   static readonly Singleton Instance=new Singleton();  
      static Singleton()  
      {  
      }  
      Singleton()  
      {  
      }  
      public static Singleton Instance  
      {  
           get  
           {  
                return Instance;  
           }  
      }  
 }  

22 : -. What are virtual destructures?

Ans.
A constructor can not be virtual but a destructor may. Use virtual destructors when you want to implement polymorphic tearing down of an object.

  23 : - What is close method? How its different from Finalize and Dispose?
 
Ans.

finalise is the process that allows the garbage collector to clean up any unmanaged resources before it is destroyed.
The finalise method can not be called directly; it is automatically called by the CLR. In order to allow more control over the release of unmanaged resources
the .NET framework provides a dispose method which unlike finalise can be called directly by code.
Close method is same as dispose. It was added as a convenience.

  24 : - What is Boxing and UnBoxing?

Ans.
Boxing is the process of converting a value type to a reference type. More specifically it involves encapsulating a copy of the object and moving it from
stack to heap. Unboxing is the reverse process.

  25 : - What is check/uncheck?

Ans.
checked: used to enable overflow checking for arithmetic and conversion functions.
unchecked: used to disable overflow checking for arithmetic and conversion functions

  26 : -What is the use of base keyword? Tell me a practical example for base keyword’s usage?

Ans.
The base keyword is used to access members of the base class from within a derived class:
* Call a method on the base class that has been overridden by another method.
* Specify which base-class constructor should be called when creating instances of the derived class.

A base class access is permitted only in a constructor, an instance method, or an instance property accessor.
It is an error to use the base keyword from within a static method.
Example:In this example, both the base class, Person, and the derived class, Employee, have a method named Getinfo. By using the base keyword,
it is possible to call the Getinfo method on the base class, from within the derived class.
// keywords_base.cs
// Accessing base class members
 using System;  
 public class Person  
 {  
 protected string ssn = "444-55-6666";  
 protected string name = "John L. Malgraine";  
 public virtual void GetInfo()  
 {  
 Console.WriteLine("Name: {0}", name);  
 Console.WriteLine("SSN: {0}", ssn);  
 }  
 }  
 class Employee: Person  
 {  
 public string id = "ABC567EFG";  
 public override void GetInfo()  
 {  
 // Calling the base class GetInfo method:  
 base.GetInfo();  
 Console.WriteLine("Employee ID: {0}", id);  
 }  
 }  
 class TestClass {  
 public static void Main()  
 {  
 Employee E = new Employee();  
 E.GetInfo();  
 }  
 }  

27 :- What are the different.NET tools which you used in projects?

Ans:Just read your question once again and thought Interviewer might be asking about the development tool you have used to develop ASP.NET projects.
So your answer can be Visual Studio 2005 or 2008 or 2010 whatever you have used, you may also tell Visual Web Developer or any other tool you might
have used to develop your ASP.NET Projects

Click Here : - More Dotnet Interview Question with Answer

website deployment in asp.net

website deployment in asp.net
Catergories :- Create Virtual Directory   ,  How i can Host website using Ftp FilZilla Software

Internet Information Services is used to make your computer a web server. If we want to have a web server for developing dynamic website or want to publish
website on our own server then we install the IIS.Internet Information Server (IIS) is a World Wide Web server, a Gopher server and an FTP server all rolled
into one. IIS means that you can publish WWW pages.
If you want to your web application accessible to any other pc in intranet or internet you need to IIS.

Below are steps for deployment:

1.Right click your website and click on Publish website.All compiles files are ready for deployment.
2.Create a backup for database whichever you are using and restore it on production server.
3.Go to server using ftp or filezila copy all compiles file on server.
4.Open Webconfig and change the connection string according to your Database name and server.
5.Create a virtual directory for this website.
6.Your website is ready.
7.Test website http://192.163.0.234(ServerName)/VDName/Login.aspx

How i can use FTP Software
Download the  ftp software from the fowlling link as give below

FileZilla software Download Link
Create Virtual Directory
after downland and install the filezilla you got the icon on the desktop or your program file .Image as shown Below

Click on the icon and open the filezilla client


Wirite the hostname and username and password
host:  ftp.domainname.com or 180.167.50.345 (this is your host IP) 
username: your username
password: your hosting passwrod


After Enter the user name and passwrod click on Quickconnect button then you wil get the message in left hand site

Status:    Directory listing successful


Friday, 19 April 2013

Ajax AsyncFileUpload control example in asp.net to upload files to server

Ajax AsyncFileUpload control example in asp.net to upload files to server


Introduction:


Here I will explain how to use Ajax AsyncFileUpload control to upload files to folder and show progress bar during upload files to server using asp.net.If you want to upload file on the web server then you do not define the path it use virtual path of our folder only set the read and write permission on the folder.

Description : -

I will explain how to use ajax AsyncFileUpload control to upload files to folder in asp.net. Before proceed to implement sample have you install ajaxcontroltoolkit in visual studio or not if not install it otherwise if you already done then follow the below steps to implement Ajax AsyncFileUpload control example in asp.net.

First create one new website after that right click on it add new folder and give name as ‘Files’ after that add AjaxControlToolkit reference to your application and add following line in your aspx page
<%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" tagPrefix="ajax" %>
Once add above references design your aspx page will be likes this
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
// This function will execute after file uploaded successfully
function uploadComplete() {
document.getElementById('<%=lblMsg.ClientID %>').innerHTML = "File Uploaded Successfully";
}
// This function will execute if file upload fails
function uploadError() {
document.getElementById('<%=lblMsg.ClientID %>').innerHTML = "File upload Failed.";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ajax:ToolkitScriptManager ID="scriptManager1" runat="server"/>
<div>
<ajax:AsyncFileUpload ID="fileUpload1" OnClientUploadComplete="uploadComplete" OnClientUploadError="uploadError"
CompleteBackColor="White" Width="350px" runat="server" UploaderStyle="Modern" UploadingBackColor="#CCFFFF"
ThrobberID="imgLoad" OnUploadedComplete="fileUploadComplete" /><br />
<asp:Image ID="imgLoad" runat="server" ImageUrl="loading.gif" />
<br />
<asp:Label ID="lblMsg" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>


If you observe above code I define lot of properties to ajax:AsyncFileUpload now I will explain all the

Now in code behind add following namespaces

C# Code 


using System;
using System.Web.UI;
using AjaxControlToolkit;

After completion of adding namespaces write following code in code behind
protected void fileUploadComplete(object sender, AsyncFileUploadEventArgs e)
{
string filename = System.IO.Path.GetFileName(fileUpload1.FileName);
fileUpload1.SaveAs(Server.MapPath("Files/") + filename);
}

VB Code

Imports System.Web.UI
Imports AjaxControlToolkit
Partial Class Default
Inherits System.Web.UI.Page
Protected Sub fileUploadComplete(ByVal sender As Object, ByVal e As AsyncFileUploadEventArgs)
Dim filename As String = System.IO.Path.GetFileName(fileUpload1.FileName)
fileUpload1.SaveAs(Server.MapPath("Files/") & filename)
End Sub
End Class

Download sample code attached







How Install Ajax in visual studio?

    1) First step is to download the latest version of the Ajax Control Toolkit from CodePlex whichever suits to your visual studio. If you are using Visual Studio 2008 then you should pick the version of the Ajax Control Toolkit for .NET 3.5. If you are using Visual Studio 2010 then you can use either the .NET 4 or .NET 3.5 versions of the Ajax Control Toolkit.


 

..




New Updates

Related Posts Plugin for WordPress, Blogger...

Related Result