Sunday, 20 May 2012

difference between response.redirect and server.transfer

  • In Server.transfer their is no round trip while Response.redirect has a round trip hence puts a load on the server.
  • Using Sever.transfer you cannot redirect to a different server itself while using Response.redirect you can redirect to a different server also.

Page Life Cycle in asp.net

Page Event Use of Event
   
PreInit
  • Check The IsPostBack Property.
  • Create and Recreate dynamic controls.
  • .Set master page and themes.
Init
  • Initialize control properties and skin settings.
  • it is used to read and write all properties.
InitComplete
  • Tracking of view state changes is turned on
PreLoad
  • Raised after the page loads view state
  • process Request Instance.
PageLoad
  • The Page object calls the OnLoad method on the Page object
  • Set Property in controls.
  • establish database connections.
Control events
  • Use these events to handle specific control events, such as a button control's Click event or a TextBox control's TextChanged event.
LoadComplete
  • Raised at the end of the event-handling stage.
PreRender
  • created all controls
PreRenderComplete
  • Raised after each data bound control whose DataSourceID property is set calls its DataBind method.
SaveStateComplete
  • Raised after view state and control state have been saved for the page and for all controls.
Unload
  • Raised for each control and then for the page.
  • In controls, use this event to do final cleanup for specific controls, such as closing control-specific database connections.
   

Thursday, 5 April 2012

Difference between struct and classes

Struct

Classes

1. The struct is value type 1. The class is reference type
2. It inherits from System.ValueType 2.It inherits from the System.Object Type
3. The struct value will be stored on the stack memory. 3.The class object is stored on the heap memory.
4. Cannot implement Inheritance 4.implement Inheritance
5.The struct can have only constructor. 5.The class can have the constructor and destructor.
6. The struct can't initialize at the time of declaration. 6. The class can have the initializes fields.

Friday, 9 March 2012

How to upload a website in asp.net




1. To Uplaod a website you have to build Your Website first

2. Go to Solution Explorer

3. Build Application To check the errors and make required changes in
webconfig File. eg connection string

4. Than again right click on application and select Publish Website option
Publish wizard will open.

5. set the loaction for precomplied folder.

6. clcik Ok

7. You will get Your Precompiled folder.

8. Now Upload that Folder on your Hosting account using any Ftp Program such
as Filezilla or cuteftp or any Other Program.

9. Enter Your Credential and Login

10 Upload Your Precomplied Folder to root folder of webhosting Account.

Conatct me at aman0716@gmail.com regarding any Problem.

Saturday, 14 January 2012

Program for Leap year Checking


#include
#include
#include
void main()
{
int year;
clrscr();
printf("enter the year=");
scanf("%d",&year);
if(year%4==0)
{
printf("Leap Year");
}
else
{
printf("not a Leap Year");
}
getch();
}
 

Write a Program to check an integer for perfect square


#include
#include
#include
void main()
{
int num,root;
clrscr();
printf("enter the number=");
scanf("%d",&num);
root=sqrt(num);
if(num==root*root)
{
printf("Perfect Square");
}
else
{
printf("not a perfect Square");
}
getch();
}
 

Conversion of Centigrade temperature to fahrenheit


 #include
#include
void main()
{
float fahr,cent;
clrscr();
printf("Enter the temperature in centigrade=");
scanf("%f",¢);
fahr=1.8*cent+32.0;
printf("%f centigrade is equals to the %f fahrenheit",cent,fahr);
getch();
}
 

Write a Program to Convert KiloMeter into Meter,Centimeter,Inch


 #include
#include
void main()
{
long int kilometer,meter,centimeter;
double inch,feet;
printf("Enter the Value in kilometer=");
scanf("%ld",&kilometer);
meter=kilometer*1000;
centimeter=meter*100;
inch=centimeter/2.5;
//feet=
printf("%ld Kilometer is Equals to %ld meter\n",kilometer,meter);
printf("%ld kilometer is Equals to %ld centimeter\n",kilometer,centimeter);
printf("%ld kilometer is Equals to %lf inch",kilometer,inch);
getch();
}

 

Sunday, 25 December 2011

Get List Of All Printers


To Getting List of All Printers First of all add a namespace
System.Drawing.Printing

use Foreach Loop:

foreach(string printer in PrinterSettings.InstalledPrinters)
{
Combobox1.Items.Add(Printer.ToString());
}

using this you get list of all printer install on your system

Saturday, 24 December 2011

Select Second Maximum From a Table in Sql

Q.Find Second Maximum From a Table in Sql

select max(duration) from course where duration<(select max(duration) from course)

OR



select min(duration) from course where duration in(select top 2 duration from course)

Wednesday, 7 December 2011

EditTable Listbox


To create a edittable list box take a list box and enter items in it.now select the list box double click event from event list.

private void listBox1_DoubleClick(object sender, EventArgs e)
{
//get list item index
int itemno = this.listBox1.SelectedIndex;
//get list item tex;
string itemvalue = this.listBox1.Items[itemno].ToString();
Rectangle rect = this.listBox1.GetItemRectangle(itemno);
this.textBox1.BackColor = Color.Aqua;
this.textBox1.BorderStyle = BorderStyle.Fixed3D;
//get list item drawing point
this.textBox1.Location = new System.Drawing.Point(rect.X + 12, rect.Y + 12);
this.textBox1.Size = new System.Drawing.Size(rect.Width + 5, rect.Height - 5);
this.textBox1.Visible = true;
this.textBox1.Text = itemvalue;
this.textBox1.Focus();
this.textBox1.SelectAll();
}

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
//if User Press Enter button
if (e.KeyChar == 13)
{
this.listBox1.Items[this.listBox1.SelectedIndex] = this.textBox1.Text;
this.textBox1.Visible = false;
}
//If User press Escape button
if (e.KeyChar == 27)
{

this.textBox1.Visible = false;
}
}

Tuesday, 22 November 2011

Interchange Values of Two numbers Without using third variable

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter First number=");
scanf("%d",&a);
printf("Enter Second number=");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("a is=%d\n",a);
printf("b is=%d",b);
getch();
}
Earn upto Rs. 9,000 pm checking Emails. Join now!

Interchange Values of Two numbers

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter First number=");
scanf("%d",&a);
printf("Enter Second number=");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("a is=%d\n",a);
printf("b is=%d",b);
getch();
}

 
Earn upto Rs. 9,000 pm checking Emails. Join now!

Monday, 21 November 2011

Write a Program to calculate area of a Rectangle

#include<conio.h>
#include<stdio.h>
void main()
{
int length,breadth,area_of_rectangle;
clrscr();
printf("Enter the Length=");
scanf("%d",&length);
printf("Enter the Breadth=");
scanf("%d",&breadth);
area_of_rectangle=length*breadth;
printf("Area of rectnagle is=%d",area_of_rectangle);
getch();
}

 

Write a Program to calculate area of a circle

#include<conio.h>
#include<stdio.h>
void main()
{
double radius,area_of_circle;
clrscr();
printf("Enter the radius=");
scanf("%lf",&radius);
area_of_circle=3.14*radius*radius;
printf("Area of Circle is=%lf",area_of_circle);
getch();
}

Tuesday, 15 November 2011

Sunday, 13 November 2011

If a five-digit number is input through the keyboard,write a program to reverse the number?

/*Reverse a Number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int number,reverse_number;
clrscr();
printf("Enter the Number you want to reverse:");
scanf("%d",&number);
/*we use while loop and '%' to seprate a number*/
printf("Reverse number is:");
while(number>0)
{
reverse_number=number%10;
number=number/10;//update number
printf("%d",reverse_number);
}
getch();
}

If a five-digit number is input through the keyboard ,write a program to calculate the sum of its digit?

/*Sum of  Digit of  a Number*/
#include
#include
void main()
{
int number,sum=0;
clrscr();
printf("Enter the Number you want to Sum its digit:");
scanf("%d",&number);
/*we use while loop and '%' to separate a number*/
printf("Sum of its digit is:");
while(number>0)
{
sum=sum+(number%10);
number=number/10;//update number
}
printf("%d",sum);
getch();
}

Concept of Strong name

strong name is used for unique id for.net assembly. it is used when we need to deploy assembly in Gac(global Assembly cache).

How to generate Strong name


go to visual studio tools> Visual studio Command Prompt

There is command prompt window With

C:\program files\visual studio 9.0\Vc\

to create strong name type sn.exe -k "c:\test.snk"


C:\program files\visual studio 9.0\Vc\sn.exe -k "c:\test.snk"

-k is key value parameter and "c:\test.snk" is location to save file


after that press enter nd u get

key pair return to "path"

For using strong Name in Class library


in Visual Studio
go to Projects > Class library1 properties. > signing

make use a key radio button Checked nd browse Location of test.snk

nd use test.snk in your Class Library

Different Methods to Pass Values between Web Forms





Untitled Document





Different Methods to Pass Values between Web Forms

Cross page posting means to post data from one page to another page.this is an important concept in web development.

there are many methods to perform this task.some of Them are following.

Cookies:

A small piece of information or message sent by the web server to User's web browser during a request, which is stored on user's system in the form of a text file(mostly as notepad file).

How to use a cookie.

//Cross Page Posting Using Cookies.
HttpCookie samplecookie = new HttpCookie("mycookie");
  samplecookie.Value = TextBox1.Text;
  samplecookie.Expires = DateTime.Now.AddHours(1);
  Response.Cookies.Add(samplecookie);
  Response.Redirect("default2.aspx");
  

ON Second page

Retrive value using cookies.

Label1.Text = Request.Cookies["mycookie"].Value;

Query String

this is another way to pass value between pages.
in it we have to use a question mark (?) as separator. "&" is use to pass multiple query strings.

how to use querystring

Response.Redirect("default2.aspx?pass="+TextBox2.Text);

Retrieve value using Querystring

Label2.Text = Request.QueryString["pass"]

Sessions

it is server side state management method.this is most secure and most acceptable way of cross page posting

how to use session on page.



Session["user"] = txtName.Text;

on second page

string str=Session["user"].ToString();