WAD Unit 1 by Tech V
WAD Unit 1 by Tech V
1) Open visual studio > file > new > web site> add new item(solution explorer)
2) In design add TextBox and Button.
3) Add literal to title in source file.
4) Double click on textbox and you got new file p1.aspx.cs
2.TAKE TWO LINKBUTTONS SHOWING “NEW MEMBER‟ AND “EXISTING MEMBER‟. WHEN USER CLICKS ON THE “NEW
MEMBER‟ LINK BUTTON PANEL1 BECOMES VISIBLE, HAVING USER NAME, PASSWORD, CONFIRM PASSWORD AND EMAIL, CITY
AS INPUTS. WHEN USER CLICKS ON “EXISTING MEMBER‟ LINK BUTTON THEN ONLY PANEL2 BECOMES VISIBLE HAVING USER
NAME AND PASSWORD AS INPUTS. SET PROPER PROPERTY OF THE TEXTBOX TO MASK THE PASSWORD. WHEN USER INPUTS IN
EXISTING MEMBER MATCHES WITH USER NAME=”ROOT” AND PASSWORD=”ABCD123” THEN PRINT “GUJARAT UNIVERSITY”
FOR 5 TIMES, EACH IN A NEW ROW WITH INCREASING FONT SIZE BY 1 EACH TIME. (USING CODE RENDER BLOCK). ELSE
DISPLAY “INVALID USER / PASSWORD”.
1) Open visual studio > file > new > web site> add new item(solution explorer
2) Add two link buttons with name new member and existing member.
3) Add 2 panels in first panel get textboxes (username, password, confirm password, e-mail, city) and one button. and second panel
4) In password properties wite textmode=password;
5) add textboxes (username, password), one button and one label.
int i=0;
if (TextBox7.Text == "Root" && TextBox6.Text == "abcd123") {
for(i=0;i<=4;i++) {
Response.Write("<font size = ‘“ + i + “px’>Gujrat University </font>" + “<br>”);
}
Label1.Text = ("Valid....");
}
else {
Label1.Text = ("username and password is invalid....");
}
Panel2.Visible = true;
10) Click ctrl + f5 to run and debugging the program.
3. DESIGN A CLASS FILE WITH TWO METHODS AS SUM AND SUBTRACTION WHICH TAKES TWO ARGUMENTS. DESIGN A WEB
PAGE TO TAKE TWO INTEGER NUMBERS FROM THE USER. WHEN USER CLICKS ON SUM OR SUBTRACTION BUTTON, DISPLAY THE
RESULT OF TWO ENTERED VALUES IN THE LABEL CONTROL PLACED ON THE WEB PAGE. (USE OF APP_CODE & BIN DIRECTORY).
1) Using App_Code :
a) Open visual studio > file > new > web site> add new item
b) Add two textboxes for values, two buttons for sum/sub and one label for display a result.
c) Right click on path > Add ASP.NET folder > App_Code
d) Right click on App_Code -> Add new item -> Class (class1.cs) >Add
namespace p3_class {
public class Class1{
public double sum(Int16 a, Int16 b) {
return (a + b);
}
public double sub(Int16 a, Int16 b) {
return (a - b);
}
}
}
c) Click Build > Build Solution in main menu.
d) click > file > new > web site> add new item
e) Add two textboxes for values, two buttons for sum/sub and one label for display a result.
f) Right click on path > add references > browse > (class file made by you recently) > Bin > Debug > .dll file and click on it.
g) Double click on sum button and write this code :
4. CREATE A RADIOBUTTONLIST THAT DISPLAYS THE NAMES OF SOME COLORS IN TWO COLUMNS. ADD A BUTTON TO THE WEB
FORM WHICH WHEN CLICKED CHANGES THE BACKGROUND COLOR OF THE FORM TO THE COLOR SELECTED FROM THE LIST.
ALSO SHOW THE USE OF EXTERNAL CSS FILE.
3) Open visual studio > file > new > web site> add new item
4) Drag RadioButtonList to our design from toolbox.
5) Enable AutoPostBack and add colors using edit items.
6) If AutoPostBack checkbox not visible then right click to div and in properties search AutoPostBack and give it value true.
7) Click add > write text of colors names.
8) Open source and give body to id=”body1” and runat=”server”.
9) Double click on radio button list and write this formula. :
Body1.Attributes.Add(“bgcolor”,RadioButtonList1.SelectedItem.Text);
10) Click ctrl + f5 to run and debugging the program.
5. CREATE A WEB PAGE HAVING CHECKBOXLIST CONTROL SHOWS DIFFERENT PRODUCTS. WEB PAGE SHOULD HAVE A
BUTTON AND A LABEL. ON THE CLICK EVENT OF THE BUTTON SHOWS THE MESSAGE “THANK YOU FOR PLACING THE ORDER OF
FOLLOWING ITEMS” AND THEN LIST OF ALL PRODUCTS SELECTED BY THE USER FROM THE CHECKBOXLIST SERVER CONTROL.
EACH SELECTED PRODUCT SHOULD BE DISPLAYED IN THE NEW LINE.
1) Open visual studio > file > new > web site > add new item
2) Drag check box list to our design from toolbox
3) Add items using edit items.
4) You can check or uncheck AutoPostBox.
5) Drag button and label to design from toolbox.
6) Write code in button in button :
int i = 0;
String str = "";
for ( i = 0 ; i <= CheckBoxList1.Items.Count – 1 ; i++) {
if (CheckBoxList1.Items[i].Selected == true) {
str += CheckBoxList1.Items[i].Text + " ";
}
}
Label1.Text = ("Thank you for placing the order of : " + str);
7) Click ctrl + f5 to run and debugging the program.
6. ACCEPT ITEM NO, ITEM NAME, ITEM PRICE, ITEM QUANTITY. STORE INFORMATION IN COOKIE. DISPLAY STORED
INFORMATION IN NEXT PAGE WITH TOTAL PRICE = PRICE * QUANTITY.
1) Open visual studio > file > new > web site> add new item
2) Add 4 textboxes for item no, item name, item price, item quantity and two buttons for store cookie or redirect to another page.
3) Add another page and get 5 labels for 4 previous and fifth is for total price.
4) Write this code to button 1 :
try {
Label1.Text = Request.Cookies["a.txt"].Values["ino"].ToString();
Label2.Text = Request.Cookies["a.txt"].Values["inm"].ToString();
Label3.Text = Request.Cookies["a.txt"].Values["ipr"].ToString();
Label4.Text = Request.Cookies["a.txt"].Values["iqu"].ToString();
Label5.Text = Request.Cookies["a.txt"].Values["tp"].ToString();
}
catch {
Response.Write("not found.");
}
7) Click ctrl + f5 to run and debugging the program.
7. TAKE SINGLE IMAGE HAVING TEXT “HOME”, “PRODUCT” AND “SERVICES” WRITTEN IN THE BOXES. WHEN USER CLICKS
ON THE FIRST RECTANGLE HOME.ASPX PAGE SHOULD BE OPENED. SIMILARLY, WHEN USER CLICKS ON THE PRODUCT
RECTANGLE THE PRODUCT.ASPX AND SERVICE RECTANGLE THEN SERVICE.ASPX SHOULD BE OPENED. USE IMAGEMAP
CONTROL.
8. USING ADROTATOR CONTROL, DISPLAY 3 IMAGES OF CAR AND WHEN USER CLICKS ON IT, OPEN WEBSITE OF IT. LOAD
9. WRITE CODE TO UPLOAD ONLY IMAGE FILES (.BMP, .JPG, .GIF) AND LESS THAN 1 KB IN FOLDER “IMAGE FOLDER”. ALSO
DISPLAY UPLOADED IMAGE FILES ON THE SAME WEB PAGE USING DATALIST CONTROL.
1) Open visual studio > file > new > web site> add new item
2) Add FileUpload, button and datalist to design from toolbox.
3) Add folder : Right click on path and create new folder name “img”.
if (s.EndsWith(".bmp") || s.EndsWith(".jpg") || s.EndsWith(".gif")) { //check image ends with bmp, jpg, gif
if (FileUpload1.FileBytes.Length < 1024) { // check image size
FileUpload1.SaveAs(s); // save image
Response.Write("image uploaded successfully....");
}
else
Response.Write("image should be less then 1 kb...");
}
else
Response.Write("File should be jpg, gif or bmp");
}
else
Response.Write("Image not found......");
5) add library using System.IO;
a) write code in Page_Load method : // if system.io library no include then this is not visible
DataList1.DataSource = f1; //
vi) Click datalist (>) arrow and click End template editing.
6) Click ctrl + f5 to run and debugging the program.
1) Open visual studio > file > new > web site> add new item
2) Add one label in design for display number of users.
3) Double click on blank page and write this code : Label1.Text = Application["cnt"].ToString();
4) Right click on path > add new item > Global Application Class > add it.