Friday, November 27, 2009

Day 5

(3)Array:-
To create a array of 4 string ,we use following syntax
string[] stringArray = new string[4];
to create array of 3 string
string[] stringArray = new string[3];
to create multidimensional array of integers
int[,] intArray = new int[2, 4];
this array contain 2 rows and 4 columns means 8 block
difference between one dimensional and multidimensional is just
a comma in bracket.
You can assign value in array like this
int[] intArray = {"1","2","3","4"};
int[,] intArray = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
Now if you want to assign a array in a variablie then
int a;
a=intarray[1,2];

Remember where is curly braces and where are square braces


(4)Array List:
It is a dynamic array.In normal array you cant change size
after you defined once.Here is syntax for dynamic array
ArrayList dynamicList = new ArrayList();

Now after initialization start flling in array


dynamicList.Add("one");
dynamicList.Add("two");
dynamicList.Add("three");


(5)Variable Operation:
+
-
*
=
/
%
number=4+ 3 +5;
Joining two strings
name=first name+""+last name;
(6)Advance Maths:
Double myValue;

myValue = Math.Sqrt(81); // myValue = 9.0
myValue = Math.Round(42.889, 2); // myValue = 42.89
myValue = Math.Abs(-10); // myValue = 10.0
myValue = Math.Log(24.212); // myValue = 3.18.. (and so on)
myValue = Math.PI; // myValue = 3.14.. (and so on)

I copied it from a book.. please dont mention

(7)Type conversion:
Converting information from one data type to another
Here how to change a 32-bit integer to a 16-bit integer:

int count32 = 1000;
short count16;

count16=(short)count32;


Take another example



int mySmallValue;
long myLargeValue;

// Get the largest possible value that can be stored as a 32-bit integer.
// .NET provides a constant named Int32.MaxValue that provides
 this number.
mySmallValue = Int32.MaxValue;
// This always succeeds. No matter how large mySmallValue is,
// it can be contained in myLargeValue.


You should remember  that a small value can not hold
a large no.It will cause a overflow and give a error
for example

int mySmallValue;
long myLargeValue;
myLargeValue = Int32.MaxValue;
myLargeValue++;
mySmallValue = (int)myLargeValue;



In C#, you can’t use casting to convert numbers to strings, or vice versa. In this case, the
data isn’t just being moved from one variable to another
But ASP.NET gives the solution


string a = "10";
int count = Convert.ToInt32(a);
it converts string value to numeric value
Now if we want to do vice versa thn


a= Convert.ToString(count);

In place of Convert you can also use parse


count = Int32.Parse(a);


Tomorrow we will finish c# .
Have a nice day




Wednesday, November 25, 2009

Day 4:C#

(1)Variable and Data types:
This is how you will declare a variable.
string Vaibhav;
int a;
You can also declare a variable by using the type name from the
.NET class library.
System.Int32 errorCode;
System.String myName;
Remember c# variable and .NET type name are different.
See
C#                         ASP.NET
int                          int32
long                       int64
short                      int16
byte                       byte
float                       single
double                   double
char                       char
string                     string
bool                       boolean
object                     object

(2)Assignment:
// Declare variables.
int a;
string myName;
// Assign values.
a = 10;
myName = "Adarsh";
or you can do this
int a=10;
string myName="Adarsh";
This doesnt make any sense..it will cause a error
int number;
number=number+1;
because you havent assigned any value
but if you do such
int number=0;
number=number+1;
than variable number will contain 1

C# also deals strictly with data types. For example, the following code statement won’t
work as written:
decimal myDecimal = 14.5;

for following strictness is applied

• M (decimal)
• D (double)
• F (float)
• L (long)
so u have to write
decimal myDecimal=14.5M;

but if you use this type of variables than you can also use
var myDecimal=14.5M

Have a nice day

Tuesday, November 24, 2009

Day 3

Now see below



   
   
this will create a div block..see in ur design view

Now start to build forms and coding in code file

(1)Use of label:
make a label in design view:

go to toolbox at the right side of Your screen...and go to standard
tools and double click label or drag it to design scren


Now first set the design properties and ID for the label.Here we set
the ID of label is "label1"

when u scroll up in properties window..you will find "text"..here You
can write any text in the label.Default is label...but you can change
as your name or something extra.
In behaviours all are true by default.If you set visibility false
then no label will show in output.

Now to display a text by a label at output window..double click on
lable and it will redirect you to code file;;

Now do this

.text="";
for example

our labelname is "label 1" and we want to print "hello"

label1.text="hello"


Now save and go to design view and right click on design window and click
preview
in browser..it will show "hello" at browser screen.


Other controls like text box,panels etc also there..but it is enough to show
how we work in asp.net.
To know others You should know some basics of c# language and some
technical terms are also important.
So may be tomorrow we will start to learn about programming concepts
in ASP.NET or probably I will write another post today.
Have a great day.........

Saturday, November 21, 2009

Day 2

Lets learn the first page:
(1)<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

Its the first line:
 Page language="C#"
whole internal coding will be in c# language
 AutoEventWireup="true"
  If you do set AutoEventWireup to true , Visual Studio will
    generate code to bind the events and the                 
age framework will automatically call events based on their names.
This can result in the same event code being called twice when the  
 page runs. As a consequence, you should always leave AutoEvent
 Wireup set to false when working in Visual Studio.May be it is   
 hard to understand..u just remember if you are new at ASP.NET
 leave it true
CodeFile="Default.aspx.cs"
do one thing, select design in three
 lower tabes and click on given div tag,it will open such type of                
  page





This is The code file for any asp.net page,If name of page is "Adarsh.aspx"
then
Name of code file will be "adarsh.aspx.cs"
Inherits="_Default"
basically it is saying that there are two objects called _Default and
you are wanting to use one of them but it does not know which one to
instantiate.and finally leave it if you are new any action on first line
can ruin your website ,so wait to work on first line.

If you are getting any parsing error than remove this and your problem will be
solved.Like this
Parser Error Message: The type '_Default' is ambiguous:.



If you want to convert any of the form fields within an HTML form into
ASP.NET controls, you must use the Runat="Server" attribute with the
opening form tag.


To convert any html Page into  ASP.NET PAGE

  1. You rename the file so that the filename ends with the extension
    .aspx.


  2. You add the attribute Runat="Server" to each of the form tags.


  3. Instead of using the NAME attribute for the form tags, you use ID
    instead.


  4. You convert the opening
    tag from
    action="SimpleASPX.aspx"> to the simpler
    .




Tomorrow we will discuss on benifits of ASP.NET,and go for some harder sections.




I am not well today,so I discussed very small section,we will increase our speed later
                                                                                                                                 

Friday, November 20, 2009

Let us Start Learning....

 FIRST THING..YOU HAVE TO KNOW BASIC HTML TO START READING
May be this section is boring...if u dont wanna read this then ok

(1)Variable Names:
    

Array
arr
arrShoppingList
Boolean
bln
blnIsPostBack
Byte
byt
bytPixelValue
Char
chr
chrDelimiter
DateTime
dtm
dtmStartDate
Decimal
dec
decAverageHeight
Double
dbl
dblSizeOfUniverse
Integer
int
intRowCounter
Long
lng
lngBillGatesIncome
Object
obj
objReturnValue
Short
shr
shrAverage
Single
sng
sngMaximum
String
str
strFirstName

Formalties like this are necessary to learn ASP.NET.I 
am 
not going to bore You..Lets Start Learning


We can use both visual basic and c# in ASP.NET but we 
will use c# here..because on net c# to vb converters 
are available


Now get to the first page..may be this is boring to 
go for basic when you see very advance websites 
on web using .NET but we have to do this..untill 
you will feel all concept as a bouncer.
ASP.NET FIRST PAGE
  To start programming in Asp.net you have to
install Microsoft visual web developer(2008 or old 
versions).
On clicking the icon of microsoft visual web developer
..You will get such screen.



Now open the file menu and click on New website and You will 
get such type of screen.choose C# in language menu.
and click ok.




 Now you will get such screen

Now we will understand the screen..
At bottom You can see three tabs are there..i am not 
going to explain them..just click them and see their 
work
At left..There is solution explorer,,it contains 
information about website contents and their links..
You can directly add your new pages are items here 
but how?we will se later
At left bottom there is properties window..
where you can set the properties of the page.