Pages

Ads 468x60px

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

.

Monday 29 July 2013

Latest asp.net interview questions and answers for experienced

Latest asp.net interview questions and answers for experienced
Introduction : -

I  have Collection new asp.net interview question and answer for experience and fresher .This is very important asp.net interview question with answer.
Every interviewer firstly ask 

1 . Tell me about Your Self ?

Ans  Good morning sir/madam.This is Chitranjan Singh Rathore My educational qualification are: I have completed my 10th standard in 2002 from  Little flower school and also 12th standard in 2004. I have completed my graduation in 2007 from Holkar science college. I have completed my post graduation in 2010 from Medicaps Colloege indore .
For More Click Here

 
2 . What is asp.net ?

Ans  Dot Net is a Framework technology, that means which is integrated with multiple technologies like windows, web, web services, etc.It is Use to develop web based, windows based application.
For More Click Here

3. Difference Between Form authentication and windows authentication ?

For Get the answer- Form authentication and windows authentication

4 . What is authentication and authorization in asp.net ?

Answer . This is very important question .every technical interview round ask this question
               authentication and authorization in asp.net

5.  What is web form ,windows form and client server architecture ?

Ans  - This is very important and interesting question.Now we will talk about(web form and windows form)

Web from :-

1 ) As we know web from use browser presentation(asp.net form has no exception )
2 ) ASP.NET Form inherits Page class (contained in System.Web.UI namespace).
3 ) Web Forms to create Web-based applications that display in a Web browser.
 4 ) Webapplications run on webservers (usually IIS)

Windows From : -

1 ) Window form has own presentation .
2 ) A Form of Windows Forms inherits Form class (contained in System.Windows.Forms namespace).
3 ) Windows Forms to create rich applications that install and run locally on a machine.
4 ) Windows forms are used in desktop based applications which heavily rely on the GDI.

Friday 26 July 2013

How to upload multiple photos using asp.net

How to upload multiple photos using asp.net
Introduction :- 

In my previous  article i have explain the Ajax-asyncfileupload-control-example in asp.net. Now in this article we will upload multiple image using single file upload control in asp.net.

Description :- 

In this Article we take on file upload control and on button on asp.net web from.This is very important article for upload multiple image in database and folder .now we upload the multiple images in a folder some  easy process

Step 1 - Create a asp.net web project and add new from like this
Open visual stdio go to File->new ->Project  and write the name of the project

Step 2 - Write click on solution explorer and add new item ->select new web form->write the name of form

step 3 -  Drag and drop the file upload control on the form
Step 4 - Drag and drop the  asp.net Button on the form
Step 5 - Drag and drop one label on the form for count how many image you have select
Step 6 - Write click on Project (Solution Explorer) and add new folder and give the name to the folder is image

Note -: Write multiple="true" for select multiple file or  image using file upload control of asp.net
Note - use this namespace    using System.IO;

Complete Source Code as shown below

<asp:FileUpload runat="server" ID="UploadImages" multiple="true"/>
    <asp:Button runat="server" ID="uploadedFile" Text="Upload" OnClick="uploadFile_Click" />
    <asp:Label ID="listofuploadedfiles" runat="server" />



double Click on asp.net button control or write click on from and select  View Code .Go to code Behind File and write a code for upload a images in folder.

Code as shown below


      HttpFileCollection fileCollection = Request.Files;
        for (int i = 0; i < fileCollection.Count; i++)
        {
        HttpPostedFile uploadfile = fileCollection[i];
        string fileName = Path.GetFileName(uploadfile.FileName);
        if (uploadfile.ContentLength > 0)
        {
        uploadfile.SaveAs(Server.MapPath("~/image/slider/") + fileName);
      
        listofuploadedfiles.Text += String.Format("{0}<br />",uploadfile.FileName);
    }
    }



Tuesday 23 July 2013

How to allow only Numeric values into a textbox

How to allow only Numeric values into a textbox
Introduction :-

In my previous article i have explained how i can use validation control in asp.net.In this article I am explain how i can allow online integer values for text box using regular expression in asp.net.

Description : -
In my Previous article i have explained how to validated form using jquery in asp.net.And i have Provided Full Description with example for  each and every  control in asp.net. Name of Controls are

RequiredFieldValidation,RangeValidator,RegularExpressionValidator,CompareValidator,CustomValidator,
CustomValidator

In this article i have explain how to validate textbox using regular expression allow only integer values

Process :-
1 : - Create a new project in asp.net and add new from and drag and drop a text box and provide the id to the textbox.In this article the id of text box is txt_priority  .
2 : - Drag and drop the Regular Expression validator on the form and set the property as show below
ID =RegularExpressionValidator1
ControtoValidate= txt_priority   [this is textbox id]
ErrorMessage=Please enter numbers only
ForColor=Red
ValidationExpression=\d+

complete example as show below


<asp:RegularExpressionValidator id="RegularExpressionValidator1"
                   ControlToValidate="txt_priority"
                   ValidationExpression="\d+"
                   Display="Static"
                   EnableClientScript="true"
                   ErrorMessage="Please enter numbers only"
                   runat="server" ForeColor="Red"/>


Wednesday 17 July 2013

How to call asp.net web service from android application

create simple drop down menu using jquery
Introduction : -

 In this  article i am explaining how to call the asp.net  asmx web service .This is very nice article for call the asmx web  service for android application.
Setp 1 ->  Open visual studio and create a new project like this

File->new->Project
And write the name of project and click ok

Step 2  -> Write click on project  add ->add new item
select  web service and click ok and write the code as shown below on our webservice.asmx



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;


[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class WebService : System.Web.Services.WebService {

    public WebService () {

        //Uncomment the following line if using designed components
        //InitializeComponent();
    }

  

    [WebMethod]
    public int Add(int a, int b)
    {
        return a + b;
    }

  
  
}

Step 3 -> Run our web service and check the output is proper or not  like this
Click on Add


Enter Values  a=10 and b=10

Then Click on Invoke and output as shown below

 
Start Android Applcation : -

step 1 -> Doble Click on eclipse IDE and  in front of you appear the GUI .
step 2 -> select File->new->Android Application Project
and fill all the filed as show in image


step 3-> Click Next->Next->Next->Next->Finish
Step 4-> On Android Application is Created

Step4->Download the jar file
ksoap2-android-assembly-2.5.5-jar-with-dependencies.jar

Step 5 -> Copy and past in libs folder and write click->Build Path->Configration Build Path

Note - If libs  folder not avable in our project then create new folder name like libs and keep this jar file

step 6 -> Now Write Click on  Project Add->New->Class  [class name like CallSoap.java]

And Write the Code as Shown Below 


import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
public class CallSoap {
    public final String SOAP_ACTION = "http://tempuri.org/Add";

    public  final String OPERATION_NAME = "Add";

    public  final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

    public  final String SOAP_ADDRESS = "http://179.45.33.245/webservice/WebService.asmx";
    public CallSoap()
    {
    }
    public String Call(int a,int b)
    {
        SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
        PropertyInfo pi=new PropertyInfo();
        pi.setName("a");
        pi.setValue(a);
        pi.setType(Integer.class);
        request.addProperty(pi);
        pi=new PropertyInfo();
        pi.setName("b");
        pi.setValue(b);
        pi.setType(Integer.class);
        request.addProperty(pi);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);

        HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
        Object response=null;
        try
        {
            httpTransport.call(SOAP_ACTION, envelope);
            response = envelope.getResponse();
        }
        catch (Exception exception)
        {
            response=exception.toString();
        }
        return response.toString();
    }
}

step 7 -> open activity_main.xml and copy and past the code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="hello" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="230dp"
        android:layout_height="wrap_content" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="232dp"
        android:layout_height="wrap_content" />
   
   
  
   

    <Button
        android:id="@+id/button1"
        android:layout_width="229dp"
        android:layout_height="wrap_content"
        android:text="submit" />

   

</LinearLayout>
 
Step 8 -> Open the MainActivity.java

And write the code as shown below

import android.R.string;
import android.os.Bundle;
import android.os.StrictMode;
import android.app.Activity;
import android.app.AlertDialog;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

    private TextView textDisplay;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy =
                new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        setContentView(R.layout.activity_main);
        Button b1=(Button)findViewById(R.id.button1);
        //textDisplay =(TextView)findViewById(R.id.text);
        //textDisplay.setText("heloo");
        final  AlertDialog ad=new AlertDialog.Builder(this).create();

        b1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                CallSoap cs=new CallSoap();
                //soapshowrecord showrec=new soapshowrecord();               
                try
                {
                    EditText ed1=(EditText)findViewById(R.id.editText1);
                    EditText ed2=(EditText)findViewById(R.id.editText2);
                    int a=Integer.parseInt(ed1.getText().toString());
                    int b=Integer.parseInt(ed2.getText().toString());
                    //EditText ed3=(EditText)findViewById(R.id.text);
                    //String record=(ed3.getText().toString());
                    ad.setTitle("OUTPUT OF ADD of "+a+" and "+b);
                   
                    //String resp1=showrec.Call1(record);
                    //record=resp1;
                   
                    String resp=cs.Call(a, b);
                    ad.setMessage(resp);
                }catch(Exception ex)
                {
                    ad.setTitle("Error!");
                    ad.setMessage(ex.toString());
                }
                ad.show(); }
        });
    }

}

Output as shown Below



Tuesday 16 July 2013

Image slider in asp.net using jquery

create simple drop down menu using jquery
 Categories :- Image Slider In asp.net with example

Introduction : -

This is very easy  to implement the slider in  asp.net .In my previous article i have explained very nice example for implement the slider in asp.net.
This is very simple and easy to use  slider in our web page. in this post you can adjust the width and height as well as time delay of image

In this article you have to include a one .js file like this



<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>

Jquey Function is like this



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

            var currentPosition = 0;
            var slideWidth = 600;
            var slides = $('.slide');
            var numberOfSlides = slides.length;
            var slideShowInterval;
            var speed = 2000;


            slideShowInterval = setInterval(changePosition, speed);

            slides.wrapAll('<div id="slidesHolder"></div>')

            slides.css({ 'float': 'left' });

            $('#slidesHolder').css('width', slideWidth * numberOfSlides);


            function changePosition() {
                if (currentPosition == numberOfSlides - 1) {
                    currentPosition = 0;
                } else {
                    currentPosition++;
                }
                moveSlide();
            }


            function moveSlide() {
                $('#slidesHolder')
                  .animate({ 'marginLeft': slideWidth * (-currentPosition) });
            }

        });

    </script>

Complete  Source As shown below

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
     <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
    <style type="text/css">
        #slideshow #slideshowWindow
        {
     
    width:512px;
    height:200px;
    margin:0;
    padding:0;
    position:relative;
    overflow:hidden;
        }

    #slideshow #slideshowWindow .slide {
    margin:0;
    padding:0;
    width:512px;
    height:384px;
    float:left;
    position:relative;
        }
   </style>

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

            var currentPosition = 0;
            var slideWidth = 600;
            var slides = $('.slide');
            var numberOfSlides = slides.length;
            var slideShowInterval;
            var speed = 2000;


            slideShowInterval = setInterval(changePosition, speed);

            slides.wrapAll('<div id="slidesHolder"></div>')

            slides.css({ 'float': 'left' });

            $('#slidesHolder').css('width', slideWidth * numberOfSlides);


            function changePosition() {
                if (currentPosition == numberOfSlides - 1) {
                    currentPosition = 0;
                } else {
                    currentPosition++;
                }
                moveSlide();
            }


            function moveSlide() {
                $('#slidesHolder')
                  .animate({ 'marginLeft': slideWidth * (-currentPosition) });
            }

        });

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <center>
    <div id="slideshow">
    <div id="slideshowWindow">
   
        <div class="slide">
            <img src="img/1.jpg" alt="http://dotnetnukes.blogspot.in"/>
        </div><!--/slide-->
       
        <div class="slide">
            <img src="img/2.jpg" alt="http://dotnetnukes.blogspot.in"/>
        </div><!--/slide-->
       
        <div class="slide">
            <img src="img/3.jpg" alt="http://dotnetnukes.blogspot.in"/>
        </div><!--/slide-->
       
        <div class="slide">
            <img src="img/4.jpg" alt="http://dotnetnukes.blogspot.in"/>
        </div>
       
    </div>
</div>
</center>
    </form> 
   
</body>
</html>




Download sample code attached






Image slider in asp net

Image slider in asp net
Introduction :- 
 In this Post i am explain how i can implement the slider in asp.net.This is very easy to implement the slider in asp.net.

Description : -

In my previous post i have explained  implement the drop down menu using jquery. Here i am explain implement the j query slider in asp.net .

In this Post first we  include the  .js and .css file in our page .Image as show below


Inculde .js and .css  on asp.net page as shown below



<head runat="server">
    <title>Slider in asp.net</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="Styles/coin-slider.js"></script>

    <link rel="stylesheet" href="Styles/coin-slider-styles.css" type="text/css" />

    <link rel="stylesheet" href="Styles/coin-slider-styles.css" type="text/css" />
</head>

In This  slider you can set the width and height of the slider image as shown below
You can control the speed and delay of image and set width and height according to you web page this script write in jqueryslider.js .Full Source Code You Can Download link are give below


$.fn.coinslider.defaults = {
        width: 700, // width of slider panel
        height: 200, // height of slider panel
        spw: 7, // squares per width
        sph: 5, // squares per height
        delay: 1000, // delay between images in ms
        sDelay: 30, // delay beetwen squares in ms
        opacity: 0.7, // opacity of title and navigation
        titleSpeed: 500, // speed of title appereance in ms
        effect: '', // random, swirl, rain, straight
        links : true, // show images as links
        hoverPause: true, // pause on hover
        prevText: 'prev',
        nextText: 'next',
        navigation: true, // show/hide prev, next and buttons
        showNavigationPrevNext: true,
        showNavigationButtons: true,
        navigationPrevNextAlwaysShown: false
    };

Complete code as shown below



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Slider in asp.net</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="Styles/coin-slider.js"></script>

    <link rel="stylesheet" href="Styles/coin-slider-styles.css" type="text/css" />

    <link rel="stylesheet" href="Styles/coin-slider-styles.css" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <center>
    <div id="games">
    <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/1.jpg" alt="http://dotnetnukes.blogspot.in" /></a>
     <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/2.jpg"alt="http://dotnetnukes.blogspot.in"  /></a>
      <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/3.jpg"  alt="http://dotnetnukes.blogspot.in" /></a>
       <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/4.jpg"  alt="http://dotnetnukes.blogspot.in" /></a>
        <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/5.jpg" alt="http://dotnetnukes.blogspot.in"  /></a>
         <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/6.jpg"  alt="http://dotnetnukes.blogspot.in" /></a>
         <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/7.jpg"  alt="http://dotnetnukes.blogspot.in" /></a>
    </div>
    </center>
    </form>

    <script>
        $('#games').coinslider();
        </script>
</body>
</html>



Download sample code attached







Monday 8 July 2013

Detecting mobile browsers in asp.net

Detecting mobile browsers in asp.net
 Introduction : -

 hello friend this is very good example for detect the mobile browser in asp.net .In this example you can restrict to user for use only mobile.And we also find the user agent of particular Mobile device.


We use the name space as shown below for regular expression


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MySql.Data.MySqlClient;
using System.Text.RegularExpressions;//this is namespace for reg. exp.


 If we restrict our site for use in mobile then we use the following code as shown below


string u = Request.ServerVariables["HTTP_USER_AGENT"];
 Regex b = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            Regex v = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            if ((b.IsMatch(u) || v.IsMatch(u.Substring(0, 4))))
            {
            Response.Write("Browsermsg:" + "This is Mobile Browser");  
      //  Response.Redirect("http://dotnetnukes.blogspot.in//mobile");
        }
    
        else
        {
            Response.Write("Browsermsg:" + "This is not Mobile Browser");
          // Response.Redirect("http://dotnetnukes.blogspot.in//Wbsite");
        }




Download sample code attached

Saturday 6 July 2013

How will you open a new page after certain interval of time

Open new page in java script after some time interval

Introduction :-
Open the new page after some time interval using asp.net

More Details :-
 In my previous article i have provide the java script remove duplicate values from array  and java script get user IP address.

In this article i have show how i can redirect to asp.net or any html page after some interval without click of any user.This type of  functionality e use in html5 game for show the instruction and after display the instruction page automatically redirect to game play screen.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="interval.aspx.cs" Inherits="interval" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Java scripts Interval and redirect to other page</title>


     <script type="text/javascript">
         var i = 0;
         function ShowCurrentTime() {
             var dt = new Date();
             document.getElementById("lblTime").innerHTML = 5 - i + " Seconds";
             i++;
             if (i == 5) {
                 setTimeout("location.href='http://dotnetnukes.blogspot.in'", 0);
             }
             window.setTimeout("ShowCurrentTime()", 1000); // 1000 equal to 1 sec
         }
</script>
</head>
<body onload="ShowCurrentTime()">
    <form id="form1" runat="server">
  
    <div>
    <label id="lblTime" style=" font-weight:bold; font-size:x-large"></label>
    </div>
    </form>
</body>
</html>


Download sample code attached







Wednesday 3 July 2013

What is Globalization and Localization in .NET

Globalization and Localization in .NET

Globalization :-

1 ) A. Globalization is the concept of developing the application in more than one language while the Localization is used for a particular language. Like if we develop the application in more than one language we need to create the resource files (.resx) by using System.

 2) Globalization is the process of designing and developing applications that function for multiple cultures

 Localizations :-

1 )  when we open the application in a particular language, then the localizations used to convert that application to the selected language.

 2)localization is the process of customizing your application for a given culture and locale. The topics in this section describe how to create ASP.NET Web applications that can be adapted to different languages and cultures."


What are in-proc and out-proc? Where are data stored in these cases?

  In-Processs : -

1 ) A. In-Proc and Out-Proc is the types of Sessions where the session data can be stored in the process memory of the server and in the separate state server. When the session data is stored in the process memory of the server, the session is called as the In-Proc server. In this case when the server is restarted, the session data will be lost

2 ) So in the in-Proc session state, the session data is stored in the Process memory of the Server where the application is running.

Out Process : -

1 ) When the session data is stored in the separate server like in state server or in Sql Server, the type of session is called as the Out-Proc session. In this case, if the server where the application is running is restarted, the session will be still remain in the separate servers.

2 )In the Out-proc session state, the session data is stored in the separate server- may be state server or in sql server.

Friday 28 June 2013

boxing and unboxing in c#

boxing and unboxing in c#
Boxing :-

  means converting value-type to reference-type.

Eg:

int I = 20;

string s = I.ToSting();

UnBoxing :- 
 means converting reference-type to value-type.

Eg:

int I = 20;

string s = I.ToString(); //Box the int

int J = Convert.ToInt32(s); //UnBox it back to an int.


Note: Performance Overheads due to boxing and unboxing as the boxing makes a copy of value type from stack and place it inside an object of type System.Object in the heap.

Value Type :-
As name suggest Value Type stores “value” directly.
For eg: 


//I and J are both of type int
I = 20;
J = I;

int is a value type, which means that the above statements will results in two locations in memory.
For each instance of value type separate memory is allocated.Stored in a Stack.
It Provides Quick Access, because of value located on stack.
 Reference Type : -

As name suggest Reference Type stores “reference” to the value.
For eg: 


Vector X, Y; //Object is defined. (No memory is allocated.)
X = new Vector(); //Memory is allocated to Object. //(new is responsible for allocating memory.)
X.value = 40; //Initialising value field in a vector class.
Y = X; //Both X and Y points to same memory location. //No memory is created for Y.
Console.writeline(Y.value); //displays 40, as both points to same memory
Y.value = 60;
Console.writeline(X.value); //displays 60.
Note: If a variable is reference it is possible to indicate that it does not refer to any object by setting its value to null;

Reference type are stored on Heap.
It provides comparatively slower access, as value located on heap.

Thursday 20 June 2013

ADO.Net Interview Questions and Answers

Late binding and Early binding in c#
 Categories : - Late Binding and Early Binding in C#.Net , Latest Inter View Question and Answer

Define  ADO.NET ?

The full form of ADO is ActiveX Data Object.

ADO.NET is one of the component in the Microsoft.NET framework which contains following features to Windows, web and distributed applications.
1. Data Access to the applications from Database in connected (Data reader object) and disconnected (Data set and data table) model.
2. Modify the data in database from application.

What is the namespace in which .NET has the data functionality class? 

namespaces provided by .NET for data management:

 1. System.Data
This contains the basic objects used for accessing and storing relational data, such as DataSet, DataTable, and DataRelation. Each of these is independent of the type of data source and the way we connect to it.

2 .System.Data.OleDB 

It contains the objects that we use to connect to a data source via an OLE-DB provider, such as OleDbConnection, OleDbCommand, etc. These objects inherit from the common base classes, and so have the same properties, methods, and events as the SqlClient equivalents.
3 .System.Data.SqlClient
 
his contains the objects that we use to connect to a data source via the Tabular Data Stream (TDS) interface of Microsoft SQL Server (only). This can generally provide better performance as it removes some of the intermediate layers required by an OLE-DB connection.

4 .System.XML
 
This contains the basic objects required to create, read, store, write, and manipulate XML documents according to W3C recommendations.

What are the Benefits of ADO.Net?

Interoperability:

 XML Format is one of the best formats for Interoperability.ADO.NET supports to transmit the data using XML format.

 Scalability:

 ADO.NET works on Dataset that can represent a whole database or even a data table as a disconnected object and thereby eliminates the problem of the constraints of number of databases being connected. In this way scalability is achieved.

 Performance:
The performance in ADO.NET is higher in comparison to ADO that uses COM marshalling.

 Programmability: 

ADO.Net Data components in Visual studio help to do easy program to connect to the database.


What are the two fundamental objects in ADO.NET?

DataReader and DataSet are the two fundamental objects in ADO.NET.

What are the major difference between classic ADO and ADO.NET?

Some major differences: 

1 : - In ADO, we have a Recordset and in ADO.NET we have a DataSet.

2 : -In Recordset, we can only have one table. If we want to accommodate more than one table, we need to  do inner join and fill the Recordset. A DataSet can have multiple tables.

3 : -All data is persisted in XML as compared to classic ADO where data is persisted in binary format.

What is the use of a data adapter?

These objects connect one or more Command objects to a DataSet object. They provide logic that would get data from the data store and populates the tables in the DataSet, or pushes the changes in the DataSet back into the data store.

1 : - An OleDbDataAdapter object is used with an OLE-DB provider
 2 : - A SqlDataAdapter object uses Tabular Data Services with MS SQL Server.

What are the different steps to access a database through ADO.NET?

The DataSet provides the basis for disconnected storage and manipulation of relational data. We fill it from a data store, work with it while disconnected from that data store, then reconnect and flush changes back to the data store if required.

C#.Net Interview Question and Answer For Freshness and Experience

Tuesday 18 June 2013

Late binding and Early binding in c#

Late binding and Early binding in c#
This is very common  question for interview so read carefully before attend the interview.It's related to OOPS concepts .

Early Binding :-

1 - In C#, early binding is a process in which a variable is assigned to a specific type of object during its declaration to create an early-bound object.

2- Early binding is also known as compile time polymorphism, static binding and static typing.

3 - During early binding, the C# compiler performs syntax and type checks to ensure that the correct parameter amount and type are passed to the method or property. 

4 - Non-virtual methods are always early bound  

5 -  Early bound just means the target method is found at compile time, and code is created that will call this. Whether its virtual or not (meaning there's an extra step to find it at call time is irrelevant). If the method doesn't exist the compiler will fail to compile the code.

6 - Example

string s = "Hello word";
s.Trim();  // Early bound call to the Trim() method


Late Binding - 

1 - Late bound means the target method is looked up at run time. Often the textual name of the method is used to look it up. If the method isn't there, bang. The program will crash or go into some exception handling scheme at run time.

2 -  Late binding is also known as Run  time polymorphism, Dynamic binding .

3 - Calling methods using reflection is an example of late binding. We write the code to achieve this as opposed to the compiler. (E.g. calling COM components.)

4 - Virtual methods are always late bound

5 - By using late binding in C# you cannot determine the error at compile time because compile time does not have any information about assembly type

6 - Example

Object Objitems;

Objitems=CreateObject("Dll Or Assembly Name");
 
Early Binding  VS Late Binding

  • Application will run faster in Early binding, since no boxing or unboxing are done here.  
  • Easier to write the code in Early binding, since the intellisense will be automatically populated 
  • Minimal Errors in Early binding, since the syntax is checked during the compile time itself. 
  • Late binding would support in all kind of versions, since everything is decided at the run time. 
  • Minimal Impact of code in future enhancements, if Late Binding is used. 
  • Performance will be code in early binding.



  • Monday 17 June 2013

    What is index in sql server

    what is index in sql server

    Indexes: -
    Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the data quicker.

    Type of Indexs :-
    Indexes are of two types.  1-:   Clustered indexes   2-: non-clustered indexes

    Clustered indexes :- 

    you create a clustered index on a table, all the rows in the table are stored in the order of the clustered index key. So, there can be only one clustered index per table.

    Non-clustered indexes :-

    Non-clustered indexes have their own storage separate from the table data storage. Non-clustered indexes are stored as B-tree structures (so do clustered indexes), with the leaf level nodes having the index key and it’s row locater. The row located could be the RID or the Clustered index key, depending up on the absence or presence of clustered index on the table.

    Advantages of Indexes :-
    1-:  If you create an index on each column of a table, it improves the query performance, as the query optimizer can choose from all the existing indexes to come up with an efficient execution plan.

    Disadvangages of Indexes :-
    1 -: At the same t ime, data modification operations (such as INSERT, UPDATE, DELETE) will become slow, as every time data changes in the table, all the indexes need to be updated.

    2-: Another disadvantage is that, indexes need disk space, the more indexes you have, more disk space is used.

    Friday 14 June 2013

    crete and read xml file in asp.net

    crete and read xml file in asp.net
    Introduction :-

    In this article i am explain how i can create a xml file dynamically in asp.net  .

    Description :-

    In my previous article i have explained how i can read the XML file in asp.net.Know i will explain how i can write data in XML file and read from the XML file which data i have inserted .

    Note :- You have no need to create a xml file manually at the running time automatically create the XML file .

     Aspx Design code as shown below



    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="read_write_xmlfile.aspx.cs" Inherits="read_write_xmlfile" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Read and write into xml file</title>


        <style type="text/css">
            .style1
            {
                text-align: left;
            }
            .style2
            {
                color: #FFFFFF;
                background-color:Olive;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <center>
        <div>
        <b style="text-align: left"><span class="style2">Read Write XML File in Asp.Net<br />
            <br />
            <br />
            </span></b><br /></div>
        <table width="50%"><tr><td width="50%" valign="top">
    <b>Employee Details:</b><br /><br />

    <table>
    <tr><td>Name:</td>
    <td><asp:Textbox id="txtName" runat="server"/></td></tr>

    <tr><td>Department: </td>
    <td><asp:Textbox id="txtDept" runat="server"/></td></tr>

    <tr><td>Location: </td>
    <td><asp:Textbox id="txtLocation" runat="server"/></td></tr>

    <tr><td colspan="2" align="right">
    <asp:Button ID="btnWriteXml" runat="server" Text="Write XML File"
            onclick="btnWriteXml_Click" style="height: 26px"/>
    </td></tr></table></td>

    <td width="50%" valign="top">Read XML File :
    <asp:Button id="btnReadXml" text="Read XML File" runat="server"
            onclick="btnReadXml_Click"/>
    <br/>
    <asp:label id="lblXml" runat="server"/></td></tr>

    </table>
        </div>
        </center>
        </form>
    </body>
    </html>


     Include the name space in code behind file for xml read and writer and Encoding.UTF8
    as shown below


    using System.Xml; //for xml
    using System.Text; //Encoding.UTF8


    Code behind  file code as shown below

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Xml; //for xml
    using System.Text; //Encoding.UTF8

    public partial class read_write_xmlfile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnWriteXml_Click(object sender, EventArgs e)
        {
            XmlTextWriter xmlWriter = new XmlTextWriter(Server.MapPath("EmployeeDetails.xml"), Encoding.UTF8);
            xmlWriter.WriteStartDocument();
            //Create Parent element
            xmlWriter.WriteStartElement("EmployeeDetails");
            //Create Child elements
            xmlWriter.WriteStartElement("Details");
            xmlWriter.WriteElementString("Name", txtName.Text);
            xmlWriter.WriteElementString("Department", txtDept.Text);
            xmlWriter.WriteElementString("Location", txtLocation.Text);
            xmlWriter.WriteEndElement();

            //End writing top element and XML document
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();
            xmlWriter.Close();
            txtDept.Text = "";
            txtLocation.Text = "";
            txtName.Text = "";

        }
        protected void btnReadXml_Click(object sender, EventArgs e)
        {
            ReadXmlFile(Server.MapPath("EmployeeDetails.xml"));
        }
        protected void ReadXmlFile(string xmlFile)
        {
            string parentElementName = "";
            string childElementName = "";
            string childElementValue = "";
            bool element = false;
            lblXml.Text = "";

            XmlTextReader xmlReader = new XmlTextReader(xmlFile);
            while (xmlReader.Read())
            {
                if (xmlReader.NodeType == XmlNodeType.Element)
                {
                    if (element)
                    {
                        parentElementName = parentElementName + childElementName + "<br/>";
                    }
                    element = true;
                    childElementName = xmlReader.Name;
                }
                else if (xmlReader.NodeType == XmlNodeType.Text | xmlReader.NodeType == XmlNodeType.CDATA)
                {
                    element = false;
                    childElementValue = xmlReader.Value;
                    lblXml.Text = lblXml.Text + "<b>" + parentElementName + "<br/>" + childElementName + "</b><br/>" + childElementValue;
                    parentElementName = "";
                    childElementName = "";
                }
            }
            xmlReader.Close();
        }
    }

     Output as shown below

    After Insert the Record into the textbox and press the button Write XML File  And Click on Read XML File  as shown below




    Download sample code attached



    read data from xml file in asp.net

    read data from xml file in asp.net
    Categories:-aspdotnet interview question and answer , create wcf restful web service in asp.net

    Introduction :-  

    Here i am explain how i can retrieve  data from XML  file in asp.net. show the data of XML file on the web form.

    Description :-

    XML stands for Extensible Markup Language.XML is a markup language much like HTML. Using xml we can store the data and we can easily retrieve and display the data without using database in our application.Using XML no need to connect any database. If  we  want to display data dynamically then we use the XML file.On the XML file we can Perform the read write and update  operation .
    Now  i will explain how i can read data from xml in asp.net.

     Design your aspx page as show below



    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="xmlpageread.aspx.cs" Inherits="xml_file_xmlpageread" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
            .style1 {
                text-align: center;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div class="style1">
      
            Enter ID
            <asp:TextBox ID="txt_id" runat="server"></asp:TextBox>
    &nbsp;&nbsp;
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />
            <br />
            <br />
            <br />
      
        </div>
        </form>
    </body>
    </html>


    In the above aspx page design i have taken a one textobx and on button .Textbox use for insert the Employee id  which present in xml file and press submit button get the detail related to this employee id.

    code behind file as show below



    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Xml;

    public partial class xml_file_xmlpageread : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
          
        }
        protected void Button1_Click(object sender, EventArgs e)
        {

            try
            {
                string empid1 = txt_id.Text.ToString();
                if (empid1 != null)
                {
                    //Response.Write("<br>XML file searching using asp.net<br><br>");
                    XmlDocument doc = new XmlDocument();

                    string xmlFile = System.Web.HttpContext.Current.Server.MapPath("~/XMLFile.xml");
                    doc.Load(xmlFile);
                    int empid = int.Parse(empid1);// convert the empid1 to int

                    XmlNodeList xmlnode = doc.GetElementsByTagName("blockid"); //this is tag of xml file
                    for (int i = 0; i < xmlnode.Count; i++)
                    {

                        XmlAttributeCollection xmlattrc = xmlnode[i].Attributes;
                        if (int.Parse(xmlattrc[0].Value) == empid)
                        {
                            Response.Write("<br>Employee-ID: " + xmlattrc[0].Value);
                            Response.Write("<br>First Name: " + xmlnode[i].ChildNodes[0].InnerText);     
                            Response.Write("<br>");
                        }
                    }
                }
            }
            catch (Exception exp)
            {
              
            }
        }
    }

    Xml Form at run time as show below

    Enter the Employee Id Into the textbox and press submit button the display the output as shown below
    figure
    Download sample code attached






     

    ..




    New Updates

    Related Posts Plugin for WordPress, Blogger...

    Related Result