الأحد، 10 أكتوبر 2010

الحلقة الاولة من تعلم ASP.NET بالغة العربية


الأحد، 12 سبتمبر 2010

Simple HOTEL RESERVATION FORM



Simple HOTEL RESERVATION FORM
Steps
1. Create a new Windows application named Hotel Reservation.
2. Drag a label onto the form and set its text to Hotel Reservation Form.
3. Set the font size to 14.
4. Set the font to bold.
5. Set the TextAlign property to MiddleCenter.
6. Drag a check box onto the form and name it chkVIP.
7. Set its background color to Green and its text to VIP Customer.
8. Drag a group box onto the form, and set its text to Room Type.
9. Drag a radio button onto the group form, set its name to rbSingle, and its text to Single.
10. Drag a second radio button onto the group form, set its name to rbDouble and its text to Double.
11. Drag a third radio button onto the group form, set its name to rbSuite, and set its text to Suite.
12. Use the format menu choice to make all three radio buttons the same size, align their left borders, and set their vertical spacing to equal.
13. Resize the group to fit the radio buttons and set the background color ofthe group to Cornflower blue.
14. Drag a checkedListBox onto the form and set its name to clbFeatures.
15. Click on the Items property and add the following features:

Whirlpool
Color TV
VCR
DVD
On-Demand Movies
In-Room Wet Bar
Free Breakfast
Free Lunch
Free Meals
Late checkout
Early check in
16. Set the Sorted property to true and watch the list sort itself.
17. Set the background color to a pleasing pastel.
18. Add a button named btnBook and set its text to Book Reservations.
Stretch the button to fit.
19. Set the button’s background color to red, set its forecolor to yellow, and set its font to bold.
20. Drag a label onto the form. Set its name to lblOutput and its text to blank.
                              Your form should now look more or less like Figure


21. Double-click on the Book Reservations button to open the event handler.
Create a string to hold the output:
string output = "Your reservation...\n";
22. Check if the VIP Customer check box is checked, if so modify the text for
the output string.
if (chkVIP.Checked == true)
output +="VIP Service!\n";
23. Check which radio button is checked and modify the output string.
if (rbSingle.Checked)
output += "Single room\n";
else if (rbDouble.Checked)
output += "Double room\n";
else
output += "Suite";
24. Add output for each feature that is selected and checked in the list.
foreach (string s in clbFeatures.CheckedItems)
output += "Feature: " + s + "\n";
25. Display the output in the label.
lblOutput.Text = output;

ASP.Net : DataList control for beginner


DataList control for beginner

The DataList control is, like the Repeater control, used to display a repeated list of items that are bound to the control. However, the DataList control adds a table around the data items by default. The DataList control may be bound to a database table, an XML file, or another list of items
Example: DataList to display pictures
Steps
1. Create a simple ASP.NET 2.0 Web Form page named StudentDetails.aspx
2. Create a folder in your site’s root and attach a collection from your favorite’s images on it as shown in figure.
1.jpg
3. Drag and Drop to a DataList control from the Data section of the Toolbox to the content area.
4. Open its smart task panel, as shown in Figure, and click Choose Data Source. Click New Data Source for the wizard to create a data source control.
2.jpg
5. Select Database as the source and leave the name as SqlDataSource1.
Use the wildcard (*) to select all fields from Student Table.
6. Run the page in your browser to test it, noticing that you don’t have the pictures yet as shown in figure. Close the browser.
3.jpg
7. Now you need to actually get the pictures displayed. Be sure your browser is closed and then in Design View select the DataList control, open its smart task panel, and click Edit Templates to see a screen similar to Figure. Select and then delete the line that has the text PictureURL and a Label control.
4.jpg
8. From the Toolbox, drag an Image control into the template just below the Picture ID field. Feel free to add a carriage return (by pressing Enter) to get the image control on its own line. On the Image control’s smart task panel, click Edit Data Bindings, and select the property ImageURL to bind to the field PictureURL, as shown in Figure.
5.jpg
9. Click ok
10. To display your data in horizontal state set these properties as shown for DataList control.
6.jpg
11. Run your page and you will see result satisfy you.
Note
In imgurl field in database I am pass the path of image as full path like this:-
images/Chrysanthemum.jpg
if I am pass the name of image only and try to run the sample we will not find image displayed in the control so to solve this case you need to change the following in source code :-
ImageUrl=’’ />

الجمعة، 30 يوليو 2010

Variable

Variables

Variables are, technically, named typed storage locations. What this means is that you can create variables to hold values of a specific type, and you can give these variables names. For example, you can declare:



General format for data type

Type anyName = yourValue;



Example:

int myAge; // declare an integer variable

myAge = 25; // assign a value to the variable



Here you’ve created a variable named myAge and you’ve declared that it will hold an int. An int is an integer variable. You then, subsequently assigned the value 25 to that variable.

Declare, Assign, Initialize

When you allocate space for the variable, you are said to declare the variable. When you give that variable a value, you are said to assign to it. You can combine these two steps into one; this is known as initializing the variable.



int myAge; // declare an integer variable

myAge = 25; // assign a value to the variable

                                          

You can combine these steps into a single initialization:



int myAge = 25; // initialize an integer variable



You can declare more than one variable on a line at a time, as long as they all have the same type:



int myFirstVar, mySecondVar, myThirdVar;

Data Type

§  A data type can be described as being either:   

§  A built-in data type, such as an int or char, or

§  A user-defined data type, such as a class or interface.



Data types can also be defined as being either:

§  Value Types (C# Reference), which store values, or

§  Reference Types (C# Reference), which store references to the actual data.

الأحد، 6 يونيو 2010

Compile Errors vs. Run-Time Errors

Compile Errors vs. Run-Time Errors

Compile errors occur each time the program is compiled. If the error exists, the compiler will find it. Run-time errors get past the compiler, but show up when the program is running. Run-time errors are not reliable; they may occur with some runs of the program, but not with others. Compile errors (sometimes referred to as compile time errors) are caught by the developer. Your Quality Assurance team may catch runtime errors, but if not, they will certainly be caught by your customers. Compile time errors are easier to find, easier to fix, and less embarrassing