Index

ASP.NET tagged Questions - Page 1

Difference between static and dynamic library in windows


- Static libraries are linked at compile time whereas dynamic libraries are linked at run-time (dynamic linking at run-time)
- Performance consideration: Static library is faster than dynamic library
- The executable exe size will be larger when we build exe with static library compared to dynamic link library

How to convert datatable to generic list in C#?


Use the following code to convert a datatable to a generic list in C#:

[C#]

DataTable dt = new DataTable {

Columns = {
{"Column1", typeof(int)},
{"Column2", typeof(string)}
}
};

for (int i = 0; i < 10000; i++) {
dt.Rows.Add(i, "Row " + i);
}

List lst = new List(dt.Rows.Count);
foreach (DataRow dr in dt.Rows) {
lst.Add(new MyType((int)dr[0], (string)dr[1]));
}

Regular expression for validating the IP Address using Javascript?


function isValidIPAddress(ipaddr) 
 {
     var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}$/;
     if (re.test(ipaddr)) 
     {
         var parts = ipaddr.split(".");
         if (parseInt(parseFloat(parts[0])) == 0) 
         {
             return false; 
         }
         for (var i=0; i<parts.length; i++)
         {
             if (parseInt(parseFloat(parts)) > 255) 
             { 
                 return false;
             }
         }
         return true;
     } 
     else 
     {
         return false;
     }
 }

What data structure would you use for a browser BACK and FORWARD ability?


Use two stacks. Every time you visit a site, push its address in stack1. When you press back, pop from stack1 and also push in stack2. When user presses forward, pop from stack2 and also push in stack1.

How to insert, delete and transverse a Sorted Linked List


#include<stdio.h>

#include<conio.h>
struct llist
{
int info;
struct llist *next;
};
typedef struct llist linked_list;
linked_list *start=NULL, *new;



void main()
{
void ll_insert();
void ll_delete();
void ll_transverse();
char menu;
do
{
printf("\n1.Insert new node");
printf("\n2.Delete node");
printf("\n3.Transverse through list");
printf("\n4.Exit\n");
menu = getchar();

switch(menu)
{
case '1': ll_insert();
break;
case '2': ll_delete();
break;
case '3': ll_transverse();
break;
case '4': return;
}
}while(menu!='4');
}

void ll_insert()
{
linked_list *createnode();
void addnode();
char ch;
do
{
new = createnode();
if(start == NULL)
start = new;
else
addnode();
fflush(stdin);
printf("\n Do you want to add one more record?\n");
ch = getchar();
}while(ch=='y' || ch == 'Y');
}

linked_list *createnode()
{
linked_list *new;
new = (linked_list *)malloc(sizeof(linked_list));
printf("Enter the number to be added:");
scanf("%d", &new->info);
new->next=NULL;
return new;
}

void addnode()
{
linked_list *ptr, *prev;

if(new->info < start->info)
{
new->next = start;
start = new;
return;
}

for(prev=start,ptr=start->next;ptr;prev=ptr,ptr=ptr->next)
{
if(new->info < ptr->info)
{
prev->next = new;
new->next = ptr;
return;
}

if(ptr == NULL)
{
prev->next = new;
}
}
}


void ll_delete()
{
linked_list *ptr, *prev, *temp;
int info;
printf("Enter the number to be deleted:\n");
scanf("%d", &info);

if(info == start->info)
{
temp = start;
start = start->next;
free(temp);
return;
}
for(prev=start,ptr=start->next;ptr;prev=ptr,ptr=ptr->next)
{
if(info == ptr->info)
{
temp = ptr;
prev = ptr->next;
free(temp);
printf("Deleted node successfully");
break;
}
}

if(ptr == NULL)
{
printf("No such element found to be deleted\n");
getch();
}

}

void ll_transverse()
{
linked_list *ptr;

if(start == NULL)
{
printf("List is empty");
return;
}



for(ptr=start; ptr; ptr=ptr->next)
{
printf("%d\n", ptr->info);
}
getch();
}

How many bits does it take to store a decimal?


128 bits

What is the Pre-Compilation feature of ASP.NET 2.0?


Previously, in ASP.NET, the pages and the code used to be compiled dynamically and then cached so as to make the requests to access the page extremely efficient. In ASP.NET 2.0, the pre-compilation feature is used with which an entire site is precompiled before it is made available to users.
There is a pre-defined folder structure for enabling the pre-compilation feature:
* App_Code: stores classes
* App_Themes: stores CSS files, Images, etc.
* App_Data: stores XML files, Text Files, etc.
* App_GlobalResources: stores all the resources at global level E.g. resx files, etc
* App_LocalResources: stores all the resources at local/Page level

What is Fragment Caching in ASP.NET?


- Fragment caching refers to the caching of individual user controls within a Web Form.
- Each user control can have independent cache durations and implementations of how the caching behavior is to be applied.
- Fragment caching is useful when you need to cache only a subset of a page.
- Navigation bars, header, and footers are good candidates for fragment caching.

What is the difference between URL and URI?


A URL (Uniform Resource Locator) is the address of some resource on the Web. A resource is nothing but a page of a site. There are other type of resources than Web pages, but that''s the easiest conceptually.
A URI is a unique identifier to usually a namespace.
Though it looks like a URL but it doesn’t have to necessarily locate any resource on the web.
URI is a generic term. URL is a type of URI.

Difference between Cookies and Session in ASP.Net


- Both session and cookies are used to store user specific information.
- If your website has got huge volume users then using session is not recommeded as it eats your memory. In such cases cookies are the best choice which saves in client machine.
- In fact both session and cookie uses cookie but in the case of cookie all information will be stored in client space but for session only sessionid will be stored in user system.
- The main advantage of sesison is you can save datasets, arryas, objects etc in session because it is saved in server memory. Cookies are normally used when you have to save small and non-critical data.

What base class do all Web Forms inherit from?


System.Web.UI.Page

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();

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.

Which two properties are on every validation control?


ControlToValidate & ErrorMessage properties

How do you create a permanent cookie?


Setting the Expires property to MinValue means that the Cookie never expires.

Which method do you use to redirect the user to another page without performing a round trip to the client?


Server.Transfer();

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.

How to manage pagination in a page?


Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.

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.

What are different methods of session maintenance in ASP.NET?


Three types of session maintenance:
In-process storage.
Session State Service.
Microsoft SQL Server.

Similar Tags