Wednesday, December 14, 2011

Asp.Net Interview Questions and Answers


                                   
  1. Whats an assembly? Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.
  2. Describe the difference between inline and code behind – which is best in a loosely coupled solution? ASP.NET supports two modes of page development: Page logic code that is written inside <script runat=server> blocks within an .aspx file and dynamically compiled the first time the page is requested on the server. Page logic code that is written within an external class that is compiled prior to deployment on a server and linked “behind” the .aspx file at run time.
  3. Explain what a diffgram is, and a good use for one? A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order.
  4. Where would you use an iHTTPModule, and what are the limitations of anyapproach you might take in implementing one? One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module.
  5. In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events? Every Page object (which your .aspx page is) has nine events, most of which you will not have to worry about in your day to day dealings with ASP.NET. The three that you will deal with the most are: Page_Init, Page_Load, Page_PreRender.
  6. Which method do you invoke on the DataAdapter control to load your generated dataset with data?
System.Data.Common.DataAdapter.Fill(System.Data.DataSet);
If my DataAdapter is sqlDataAdapter and my DataSet is dsUsers then it is called this way:
sqlDataAdapter.Fill(dsUsers);
  1. Which template must you provide, in order to display data in a Repeater control? ItemTemplate
  2. How can you provide an alternating color scheme in a Repeater control?
AlternatingItemTemplate Like the ItemTemplate element, but rendered for every other
row (alternating items) in the Repeater control. You can specify a different appearance
for the AlternatingItemTemplate element by setting its style properties.
  1. What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?
You must set the DataMember property which Gets or sets the specific table in the DataSource to bind to the control and the DataBind method to bind data from a source to a server control. This method is commonly used after retrieving a data set through a database query.
  1. What base class do all Web Forms inherit from?
    System.Web.UI.Page
  2. What method do you use to explicitly kill a user’s session?
The Abandon method destroys all the objects stored in a Session object and releases their resources.
If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.
Syntax: Session.Abandon
  1. How do you turn off cookies for one page in your site?
    Use the Cookie.Discard Property which Gets or sets the discard flag set by the server. When true, this
    property instructs the client application not to save the Cookie on the user’s hard disk when a session ends.
  2. Which two properties are on every validation control? ControlToValidate & ErrorMessage properties
  3. How do you create a permanent cookie? Setting the Expires property to MinValue means that the Cookie never expires.
  4. Which method do you use to redirect the user to another page without performing a round trip to the client? Server.transfer()
  5. What is the transport protocol you use to call a Web service? SOAP. Transport Protocols: It is essential for the acceptance of Web Services that they are based on established Internet infrastructure. This in fact imposes the usage of of the HTTP, SMTP and FTP protocols based on the TCP/IP family of transports. Messaging Protocol: The format of messages exchanged between Web Services clients and Web Services should be vendor neutral and should not carry details about the technology used to implement the service. Also, the message format should allow for extensions and different bindings to specific transport protocols. SOAP and ebXML Transport are specifications which fulfill these requirements. We expect that the W3C XML Protocol Working Group defines a successor standard.
  6. True or False: A Web service can only be written in .NET. False.
  7. What does WSDL stand for? Web Services Description Language
  8. What property do you have to set to tell the grid which page to go to when using the Pager object?
  9. Where on the Internet would you look for Web services? UDDI repositaries likeuddi.microsoft.com, IBM UDDI node, UDDI Registries in Google Directory, enthusiast sites likeXMethods.net.
  10. What tags do you need to add within the asp:datagrid tags to bind columns manually? Column tag and an ASP:databound tag.
  11. How is a property designated as read-only? In VB.NET:
Public ReadOnly Property PropertyName As ReturnType
  Get             ‘Your Property Implementation goes in here
  End Get
End Property
in C#
public returntype PropertyName
{
   get{
           //property implementation goes here
   }
   // Do not write the set implementation
}
  1. Which control would you use if you needed to make sure the values in two different controls matched? Use the CompareValidator control to compare the values
    of 2 different controls.
  2. True or False: To test a Web service you must create a windows application or Web application to consume this service? False.


25.    What is ASP.Net? What are the advantages ASP.Net Technologies?
ASP.Net is a server side Technology to develop a web based applications.ASP.Net will make use of .Net framework features.
Advantages of ASP.Net
·         ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model
·         ASP.NET offers built-in security features through windows authentication or other authentication methods.
·         Content and program logic are separated which reduces the inconveniences of program maintenance.
·         Built-in caching features.
26.    What are different stages of ASP.Net Page Life cycle?
Each ASP.Net Web page performs following stages/events
·         Page Initialization (Page_Init event)
·         Page Loading (Page_Load event)
·         Page Prerender (Page_Prerender)
·         Page Render (Page_Render)
·         Page Unload (Page_Unload)
Visit following link for more information at  ASP.Net Page Life Cycle
27.    How do you validate Input data on web page?
Before submitting a web page to server, Input validation on web page is one of the important task.ASP.Net provides below validation controls to validate data in web controls and shows user friendly Messages to the user.
ASP.Net validation Controls
  1. Required field validator control
  2. Compare validator control
  3. Range Validator Control

28.    what are the different state management techniques in ASP.Net?
Asp.Net state management can be maintained in two ways as below
Client- Side State Management
ASP.Net provides following techniques to store state information. This will improve application performance by minimizing server resource utilization
1.View state
2. Hidden Fields
3. Cookies
4. Query Strings
Server – Side State Management
With respect to Server Side State Management ASP.Net uses “Application state” and “Session state” objects to store data or user state.
29.    What are the differences between custom Web control and user control?
Custom Web control is a control that inherits from web server control available in ASP.Net.
A Custom Web Control could be compiled into separate .dll file. This custom Web control can be shared across all application by installing this dll in to Global Assembly Catch.
User Control is a file (.ascx file) that contains a set of ASP.Net controls and code grouped together to provide common functionality across the application. User control can be used on different web pages of the application.
30.    Explain ASP.Net Catching? What are different catching mechanisms available in ASP.Net?
ASP.Net catching one of the important performance factor for large web applications.
ASP.Net Catching stores frequently accessed data in to catch object.
There are two different types catching in ASP.Net
1.Application Catching
2.Page Output Catching

how to debug SP in sql server 2008


 If you have worked in SQL Server 2000 and were used to using the T-SQL debugger, you might have lamented it’s absence in SSMS in SQL Server 2005. In SQL Server 2005, one can debug the stored procedures using Visual Studio though and that works really great as well. In SQL Server 2008, MSFT has re-introduced the debugger into SSMS. In today’s post, we will pick up a stored procedure in the AdventureWorks database and will go through the features of the debugger – it is nothing different than other debuggers that you have used but it is nice to know that for folks who rely on using only SSMS for their stored procedure work, they do not need to use VS to help debug in an effective manner.
In the BOL, all of the information pertaining to the debugger is under Transact-SQL Debugger. If you have both the client tools and the server running on the same machine, then there is no configuration needed to use the debugger. However, if you are using the client tools from one machine to connect to the database server on another machine, then you need to enable port and program exceptions by using the Windows Firewall Control Panel application on both the client and the server.  We will look into those and other security related issues pertaining to the debugger in an upcoming post.  In this post, we just want to go through an example of the debugger.
So, let’s prepare an execution script for executing a stored procedure in the Adventure Works database: 
declare @x datetime
select @x = GETDATE()
exec [uspGetBillOfMaterials] 799, @x
And now, press the debug button as shown in the image below – this will launch the debugger:
Once the debugger launches, you will see the different debug options at the top – Step Into, Step Over, Step Out, breakpoints etc. and at the bottom, you will see two windows – one for the local variables/Watch and the other one a call stack/Breakpoints/Command Window and the Output – these are tabbed interfaces.  Here is the image that shows that:
And now, let’s step into the call to the procedure and you will see the local variable values and in the call stack, you will see the actual call.
This particular procedure only has a CTE which executes and returns back the records so it will exit out as we process through it and will return back the records.  Using the debugger, troubleshooting issues becomes easier especially in the case of larger procedures and the nested procedures which call other procedures or views/functions.

Dynamic insert into variable table statement SQL Server


Table:
DECLARE @A_Table TABLE(ID INT, att1 VARCHAR(100), att2 nvarchar(200))
Then,I need to make dynamic sql statement, so I insert into this table some data (all inside a loop):
WHILE (@i <= 100) BEGIN         
  SELECT @other_att  = NAME  FROM @other_Table where ID =  @i;
  SET @sql = 'INSERT ' + @A_Table+ '(ID,att1,att2) SELECT '+CAST(@i AS VARCHAR)+' , '''+ @other_att+''', SUM('+ @other_att') FROM '+ @EVEN_OTHER_Table;
EXEC (@sql);
END 

Tuesday, December 13, 2011

How do I get the height and width of a pdf file


When creating your PDF please use either our supplied Plug-in for correct specs or our book size specification calculator (if you are using a different creation tool) to determine exact page and cover sizes. Otherwise, although you might be able to upload your PDF, it will fail the post-upload preflight check.

There are few ways to determine the width and height of your existing PDF.  
1. Launch and open your PDF with Adobe Reader
2. From the menus choose File > Properties
3. The Document Properties window will be presented
4. Under the "Description" tab, near the bottom of the window you will see the "Page Size" label
5. This is the width and height of your PDF in the preferred units. You can change the unit of measurement if desired in the Reader preferences under the "Units" section.

To change your PDF dimensions you will need to return to your original design application and adjust the page size from there. Once your PDF dimensions are set, you can proceed to upload.

Wordpress Notice PopUp


I Give Away My Popup Opt-in Form plug-in for Wordpress FREE!

Hi fellow marketers,
If you’re one of the blogger who cares about building list in your niche market.
You may feel pain when you want to setup a cool popup opt-in form in your blog.
Other of that, you may want it to …
- Automatically pop-up when the page was loaded, using a cool effect.
- Put the same opt-in form in any place in your blog.
- Put the cover image and popup opt-in form when visitor click on it.
If you’re using Wordpress as your blog platform and using Aweber as autoresponder system.
Don’t miss this cool plug-in.
No risk as I give you for FREE!
If you want to build your list on your blog but don’t have autoresponder yet. Just click here.

Wednesday, November 9, 2011

palindromic string that retrieve value from the braces


public static bool IsPalindrome(string s)
{
    int iLength, iHalfLen;
    iLength = s.Length - 1;
    iHalfLen = iLength / 2;
    for (int i = 0; i <= iHalfLen; i++)
    {
        if (s.Substring(i, 1) != 
            s.Substring(iLength - i, 1))
        {
            return false;
        }
    }
    return true;
}

static void Main(string[] args)
{
    Console.WriteLine("\nPalindromes?");
    string[] sa = new string[]{
        "level", "minim", "radar", 
        "foobar", "rotor", "banana"};

    foreach (string v in sa)
        Console.WriteLine("{0}\t{1}", 
            v, StringEx.IsPalindrome(v));
}
OUTPUT
Palindromes?
level   True
minim   True
radar   True
foobar  False
rotor   True
banana  False

Wednesday, November 2, 2011

How to create a column that will autogenerate


If it is just for display, not for changing the serial number in the database, try a TemplateField column like this:

C# Example:
<asp:TemplateField HeaderText="S.NO">    <ItemStyle Width="30px" />
                                     <ItemTemplate>
                                       <%# Container.DataItemIndex + 1 %>.&nbsp;
                                     </ItemTemplate>
                        </asp:TemplateField>

VB.Net Example:

VB.NET:
<asp:TemplateField HeaderText="S.No" >
   <ItemTemplate>   
       <%# CType(Container, GridViewRow).RowIndex + 1%>
   </ItemTemplate>
</asp:TemplateField>
C#:

Tuesday, November 1, 2011

Export Gridview to Excel in asp.net

//In Button Click


HtmlForm form = new HtmlForm();
        string attachment = "attachment; filename=Report.xls";
        Response.ClearContent();
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "application/ms-excel";
        StringWriter stw = new StringWriter();
        HtmlTextWriter htextw = new HtmlTextWriter(stw);
        form.Controls.Add(GridView1);
        this.Controls.Add(form);
        form.RenderControl(htextw);
        Response.Write(stw.ToString());
        Response.End();