Google


Earn money without investing 1$

lovebird-mails.com lovebird-mails.com

Wednesday, August 8, 2007

what is user control?

These are like .aspx pages.The extension is .ascx.It supports caching mechanism in the project.We can also create our own user control and add them in the tool box as how we have in our toolbox.

Urgent Variable in SSIS package?

How to use global variable in Microsoft SSIS (DTS) package

http://www.codeproject.com/useritems/global_variable_in_SSIS.asp

y autoeventwireup attribute will be set to false?

http://www.codeproject.com/aspnet/AutoEventWireup.asp

what is the major difference between 1.1 an 2.0?

http://msdn2.microsoft.com/en-us/library/t357fb32(VS.80).aspx

Difference between Cloning and Copying(Very Important)

Copy will copy the structre as well as Data to another object.

Clone will create a copy of that structure with default values.
class object{
public int i = 0;
public object(){
}
}

Object ob1 = new Object();
ob1.i = 4;
Response.write(ob1.i);//Result 4
Object ob2 = ob1;
Response.write(ob2.i);//Result 4
Object ob3 = ob1.clone();
Response.write(ob3.i);//Result 0.

How to use Query string in our program?

webform1.aspx?id="+somevalue what u want to send+";

It is seen in the url when u redirect to other page.It is seen in the url of the site.
To store the querystring u have write some code in the page itself as mentioned below
string str = QueryString["id"];

Download XML notepad

Download XML notepad from here

http://www.microsoft.com/downloads/details.aspx?FamilyID=72d6aa49-787d-4118-ba5f-4f30fe913628&DisplayLang=en

Some useful javascript function using regular expression

Most of the time we require to validate the control in the client side using javascript.Below are some useful function


For removing blank spaces with regular Expression-----------------------

function trimAll(value)
{
var temp = value;
var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
if (obj.test(temp))
{
temp = temp.replace(obj, '$2');
}
var obj = / +/g;
temp = temp.replace(obj, " ");
if (temp == " ")
{
temp = "";
}
return temp;
}

For Zip code validation US Zip Code------------------------------------------

function isValidZipCode(val)
{
var exp=/(^\d{5}$)(^\d{5}-\d{4}$)/;
var re = new RegExp(exp);
return (val.match(re));
}

For checking Alphanumeric value-----------------------------------
function CheckAlphanumeric (e)
{
var key;
key = e.which ? e.which : e.keyCode;
if((key>=48 &&amp; key<=57)(key>=65 && key<=91) (key >=97 && key<=123)) {
e.returnValue= true;
}
else
{
alert("please enter Alphanumeric only");
e.returnValue = false;
}
}
Time in 12 hour foramt-----------------------------------------------

function validateTime(strValue,state)
{
var objRegExp = /^([1-9]1[0-1]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/;
if(!(objRegExp.test( strValue )))
{
alert("Please Enter "+ state +" time in 12 hour format eg 11:30 ");
}
return objRegExp.test( strValue );
}

Hope this will help all

Namespace in c#

Namespace

C# namespace allow us to organize our class.unlike a file and component namespace provide us a flexibility to group our class and other types
For eg
Namespace MyCustomNameSpace
{
using System;
public int show()
{
return 0;
}
}
Using keyword in C#
C# allows us to abbreviate a class full name for doing this we have to list the class namespace at the top of the file with the “Using” key word
Eg
Using MyNameSpace.CsharpExample
Class MyClass
{
public static int Main()
{
SomeOtherNameSpace.SomeOtherClass loMyObj = new SomeOtherNameSpace.SomeOtherClass loMyObj();
Return 0;
}
}
Namespace Aliases
The another use of the namespace in c# is creating aliases.this is use ful when we have a long namespace for eg
Using myAliases = MyNameSpace.CsharpExample;

Easier way to add a DLL to the GAC

To quickly add assemblies to the GAC - a registry key can be created
which allows you to right click the DLL and 'GAC it' in one click.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\dllfile\shell\gacutil\command]
@="c:\\windows\\Microsoft.NET\\Framework\\v1.1.4322\\gacutil.exe /i
\"%1\""

Reference link
http://markharrison.co.uk/blog/2005/12/easier-way-to-add-dll-to-gac.htm

Check Valid user using LDAP

The below function will authenticate user using Active Directory.


public bool IsAuthenticated(string domain, string username, string pwd)

{

string _path;

string _filterAttribute;

string servername = "ServerName"; // Give the server Name

string domainAndUsername = domain + "\\" + username;

DirectoryEntry entry = new DirectoryEntry("LDAP://" + servername, domainAndUsername, pwd);

try

{

object obj = entry.NativeObject;

DirectorySearcher search = new DirectorySearcher(entry);

search.Filter = "(SAMAccountName=" + username + ")";

search.PropertiesToLoad.Add("cn");

SearchResult result = search.FindOne();

if (result == null)

{

return false;

}

_path = result.Path;

_filterAttribute = ((string)(result.Properties["cn"][0]));

}

catch (Exception ex)

{

return false;

}

return true;

}

Convert string to byte array and vice-versa

This code sample shows how to convert a string to a byte array and and byte array to string.

//function to convert string to byte array
public static byte[] ConvertStringToByteArray(string stringToConvert)
{
return (new UnicodeEncoding()).GetBytes(stringToConvert);
}

//function to convert byte array to string
public static string ConvertByteArrayToString(byte[] byteArray)
{
return (new UnicodeEncoding()).GetString(byteArray);
}

Random number generator function in c#

Hi All,
Some time we need to generate random sequence of alphanumeric /nemeric/character for password/key etc. Below is static function which takes integer as parameter for the length of the output.

private static string RandomNumberGenerator(int length)
{
RandomNumberGenerator rng = RandomNumberGenerator.Create();
char[] chars = new char[length];
string validChars = "abcdefghijklmnopqrstuvwxyzABCEDFGHIJKLMNOPQRSTUVWXYZ1234567890"; //based on your requirment you can take only alphabets or number
for (int i=0; i< length; i++)
{
byte[] bytes = new byte[1];
rng.GetBytes(bytes);
Random rnd = new Random(bytes[0]);
chars[i] = validChars[rnd.Next(0,61)];
}
return (new string(chars));
}

ASP.NET 2.0 tutorial

Hi All,

Below is the link for asp.net 2.0 tutorial.Its really nice have a look at it

http://msconline.maconstate.edu/tutorials/ASPNET20/default.htm
Happy coding

Monday, July 30, 2007

What is ViewState?

ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks.

Explain what a diffgram is, and a good use for one?

The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.

What is the transport protocol you use to call a Web service?

SOAP (Simple Object Access Protocol) is the preferred protocol.

Explain what a diffgram is, and a good use for one?

The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.

What data types do the RangeValidator control support?

Integer, String, and Date.

What’s a bubbled event?

When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.

Is it possible to generate the source code for an ASP.NET Web service from a WSDL?

The Wsdl.exe tool (.NET Framework SDK) can be used to generate source code for an ASP.NET web service with its WSDL link.

Example: wsdl /server http://api.google.com/GoogleSearch.wsdl.

Why do some web service classes derive from System.Web.WebServices while others do not?

Those Web Service classes which employ objects like Application, Session, Context, Server, and User have to derive from System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.

What classes are needed to send e-mail from an ASP.NET application?

The classes MailMessage and SmtpMail have to be used to send email from an ASP.NET application. MailMessage and SmtpMail are classes defined in the .NET Framework Class Library's System.Web.Mail namespace.

How does System.Web.UI.Page's IsPostBack property work?

IsPostBack checks to see whether the HTTP request is accompanied by postback data containing a __VIEWSTATE or __EVENTTARGET parameter. If there are none, then it is not a postback.

Why does the control's PostedFile property always show null when using HtmlInputFile control to upload files to a Web server?

This occurs when an enctype="multipart/form-data" attribute is missing in the form tag.

How do I create an ASPX page that periodically refreshes itself?

The following META tag can be used as a trigger to automatically refresh the page every n seconds:

meta equiv="Refresh" content="nn"

Can two different programming languages be mixed in a single ASPX file?

ASP.NET’s built-in parsers are used to remove code from ASPX files and create temporary files. Each parser understands only one language. Therefore mixing of languages in a single ASPX file is not possible.

What is an interface and what is an abstract class?

In an interface, all methods must be abstract (must not be defined). In an abstract class, some methods can be defined. In an interface, no accessibility modifiers are allowed, whereas it is allowed in abstract classes.

Enumerate the types of Directives.

  1. @ Page directive
  2. @ Import directive
  3. @ Implements directive
  4. @ Register directive
  5. @ Assembly directive
  6. @ OutputCache directive
  7. @ Reference directive

When was ASP.NET released?

ASP.NET is a part of the .NET framework which was released as a software platform in 2002.

Explain Windows Forms?

Windows Forms is employed for developing Windows GUI applications. It is a class library that gives developers access to Windows Common Controls with rich functionality. It is a common GUI library for all the languages supported by the .NET Framework.

What is the difference between Server.Transfer and Response.Redirect?

  1. Response.Redirect: This tells the browser that the requested page can be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.
  2. Server.Transfer: It transfers execution from the first page to the second page on the server. As far as the browser client is concerned, it made one request and the initial page is the one responding with content. The benefit of this approach is one less round trip to the server from the client browser. Also, any posted form variables and query string parameters are available to the second page as well.

What is Data Binding?

Data binding is a way used to connect values from a collection of data (e.g. DataSet) to the controls on a web form. The values from the dataset are automatically displayed in the controls without having to write separate code to display them.

What is Code-Behind?

Code-Behind is a concept where the contents of a page are in one file and the server-side code is in another. This allows different people to work on the same page at the same time and also allows either part of the page to be easily redesigned, with no changes required in the other. An Inherits attribute is added to the @ Page directive to specify the location of the Code-Behind file to the ASP.NET page.

Explain the differences between server-side and client-side code?

Server side scripting means that all the script will be executed by the server and interpreted as needed. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Since the code is included in the HTML page, anyone can see the code by viewing the page source. It also poses as a possible security hazard for the client computer.

Explain the differences between server-side and client-side code?

Server side scripting means that all the script will be executed by the server and interpreted as needed. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Since the code is included in the HTML page, anyone can see the code by viewing the page source. It also poses as a possible security hazard for the client computer.

Explain the differences between server-side and client-side code?

Server side scripting means that all the script will be executed by the server and interpreted as needed. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Since the code is included in the HTML page, anyone can see the code by viewing the page source. It also poses as a possible security hazard for the client computer.

What is DLL Hell?

DLL hell is the problem that occurs when an installation of a newer application might break or hinder other applications as newer DLLs are copied into the system and the older applications do not support or are not compatible with them. .NET overcomes this problem by supporting multiple versions of an assembly at any given time. This is also called side-by-side component versioning.

What is Shadow Copy?

In order to replace a COM component on a live web server, it was necessary to stop the entire website, copy the new files and then restart the website. This is not feasible for the web servers that need to be always running. .NET components are different. They can be overwritten at any time using a mechanism called Shadow Copy. It prevents the Portable Executable (PE) files like DLLs and EXEs from being locked. Whenever new versions of the PEs are released, they are automatically detected by the CLR and the changed components will be automatically loaded. They will be used to process all new requests not currently executing, while the older version still runs the currently executing requests. By bleeding out the older version, the update is completed.

List the various stages of Page-Load lifecycle.

  • Init()
  • Load()
  • Prerender()
  • Unload()

What is CLI?

The CLI is a set of specifications for a runtime environment, including a common type system, base class library, and a machine-independent intermediate code known as the Common Intermediate Language (CIL).

What is CLR?

Common Language Runtime (CLR) is a run-time environment that manages the execution of .NET code and provides services like memory management, debugging, security, etc. The CLR is also known as Virtual Execution System (VES).

List the types of Authentication supported by ASP.NET.

  • Windows(Default)
  • Forms
  • Passport
  • None(Security disabled)

How should I check whether IIS is installed or not?

To verify if IIS is installed, go to your 'Add or Remove Programs' utility in the Control panel and click on the 'Add/Remove Windows Components' in the side menu.

On XP Pro and below, you should see an item called "Internet Information Services (IIS)". If this is checked, IIS should be installed.

On Win2K3, you'll see "Application Server". If this is checked, select it and then click 'Details'. Another form should open which will contain "Internet Information Services (IIS)". If it is checked, IIS should be installed.

What is .NET?

Microsoft .NET is the Microsoft strategy for connecting systems, information, and devices through Web services, so people can collaborate and communicate more effectively. .NET technology is integrated throughout Microsoft products, providing the capability to quickly build, deploy, manage, and use connected, security-enhanced solutions through the use of Web services.

Sunday, July 29, 2007

Describe the difference between inline and code behind?

Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

Explain what a diffgram is, and a good use for one?

The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.

Which method do you invoke on the DataAdapter control to load your generated dataset with data?

The Fill() method.

What namespace does the Web page belong in the .NET Framework class hierarchy?

System.Web.UI.Page

What methods are fired during the page load?

1.Init() - when the page is instantiated.
2.Load() - when the page is loaded into server memory.
3.PreRender() - the brief moment before the page is displayed to the user as HTML
4.Unload() - when page finishes loading.

Saturday, July 28, 2007

What’s the difference between Response.Write() andResponse.Output.Write()?

Response.Output.Write() allows you to write formatted output.

Differences between ASP.NET and VB.NET?

ASP.Net is an “environment”, and VB.Net is a programming language. You can write ASP.Net pages (called “Web Forms” by Microsoft) using VB.Net (or C#, or J# or Managed C++ or any one of a number of .Net compatible languages).
Confusingly, there is an IDE that Microsoft markets called VB.Net, which allows you to write and compile programs (WinForms, WebForms, class libraries etc) written in the language VB.Net
ASP.Net is simple a library that makes it easy for you to create web applications that run against the .NET runtime (similar to the java runtime).
VB.Net is a language that compiles against the common language runtime, like C#. Any .NET compliant language can use the asp.net libraries to create web applications.
Note : Actually there is not an IDE called VB.Net. Microsoft’s IDE is called Visual Studio.Net which can be used to manage VB.Net, C#, Eiffle, Fortran, and other languages.

A dozen .NET question

Differences between DLL and EXE?
Can an assembly have EXE?
Can a DLL be changed to an EXE?
Compare & contrast rich client (smart clients or Windows-based) & browser-based Web application
Compare Client server application with n-Tier application
Can a try block have more than one catch block?
Can a try block have nested try blocks?
How do you load an assembly at runtime?
If I am writing in a language like VB or C++, what are the procedures to be followed to support .NET?
How do you view the methods and members of a DLL?
What is shadowing?
What are the collections you’ve used?

What is ADO .NET and what is difference between ADO and ADO.NET?

ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.

Can the validation be done in the server side? Or this can be done only in the Client side?

Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.

How do you validate the controls in an ASP .NET page?

Using special validation controls that are meant for this. We have Range Validator, Email Validator.

What is view state?

The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control

What is smart navigation?

The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.

How ASP .NET different from ASP?

Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.

How is .NET able to support multiple languages?

A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.

How many languages .NET is supporting now?

When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Now .net supports 44 language

Friday, July 27, 2007

What is Thread?

A thread is the basic unit to which the operating system allocates processor time

Where is the version information stored of an assembly?

Version information is stored in assembly in manifest

Difference between Namespace and Assembly?

  • Assembly is physical grouping or logical units.Namespace logically groups classes.
  • Namespace can span multiple assembly

Friday, July 6, 2007

.Net Internet Standard

  • HTTP protocol ,the communication between internet applications
  • XML, the format for exchanging data between internet applications.
  • SOAP,the standard format for requesting webservices.
  • UDDI,the standard to search and discover webservice

Thursday, July 5, 2007

what does the word immutable mean?

The data value may not be changed

what is .net?

  • it is a platform netural framework.
  • it is a layer between the operating system and the programming language.
  • it supports many programming languages including c#,vb.net etc.
  • .net provides a common set of class libraries,which can be accessed from any .net based programming language.
  • in future versions of windows,.net will be freely distributed as part of operating system and users never have to install the .net separately.

What is MSIL?

MSIL stands for microsoft intermediate language.A .NET programming language doesnot compile into executable code;instead it compiles into an intermediate code called Microsoft intermediate language.It is platform independent.

What is managed code?

A code that the run time is called managed code.The code that dont targets the runtime is called unmanaged code.

What is assembly?

An assembly is a primary building block of .net framework application.It is a collection of functionality that is built,versioned and deployed as a single implementation unit.

What is WSDL?

WSDL stands for webservice description language

What is the standard you use to wrap up a call to a web service?

Http with SOAP

Review Books

  • ASP.NET WebService
  • Learn VisualStudio.net
  • Basic .NET Framework
  • Basic C#
  • .NET Interview Questions
  • C# 2005 Programming