0% found this document useful (0 votes)
19 views6 pages

WAD Unit 1 by Tech V

The document outlines a series of programming tasks for creating web applications using Visual Studio, covering functionalities such as user input forms, data handling with cookies, image uploads, and dynamic content display. It includes detailed steps for implementing features like user authentication, arithmetic operations, color selection, and advertisement display using various controls like TextBox, Button, RadioButtonList, and AdRotator. Each task provides a structured approach to coding and debugging, ensuring a comprehensive understanding of web development concepts.

Uploaded by

hetalvadaliya19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views6 pages

WAD Unit 1 by Tech V

The document outlines a series of programming tasks for creating web applications using Visual Studio, covering functionalities such as user input forms, data handling with cookies, image uploads, and dynamic content display. It includes detailed steps for implementing features like user authentication, arithmetic operations, color selection, and advertisement display using various controls like TextBox, Button, RadioButtonList, and AdRotator. Each task provides a structured approach to coding and debugging, ensuring a comprehensive understanding of web development concepts.

Uploaded by

hetalvadaliya19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.CREATE A FORM WHICH TAKES USER NAME IN TEXTBOX CONTROL.

ON THE CLICK EVENT OF THE BUTTON, NAME OF THE


USER AND CURRENT DATE & TIME WILL BE DISPLAYED ON THE TITLE BAR OF THE WEB PAGE. (USING LITERAL CONTROL). ALSO
SHOW THE USE OF CSS PROPERTY TO CHANGE THE TEXT COLOR OF A BUTTON CONTROL USING INTERNAL AND EXTERNAL CSS.

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

5) Write Literal1.Text = Textbox1.Text + DateTime.Today;


6) Get style tag and add inline CSS.
7) Also get link tag in header and get one css file from solution explorer. (default name is stylesheet.css)
8) In this we use inline, internal, and external CSS.
9) Click ctrl + f5 to run and debugging the program.

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.

6) Write this code in Page_Load : Panel1.Visible = false;


Panel2.Visible = false;
7) Write this code in LinkButton1_click (New member ): Panel1.Visible = true;
Panel2.Visible = false;
8) Write this code in LinkButton2_Click (Existing Member) : Panel1.Visible = false;
Panel2.Visible = true;
9) Write this code in Button2_Click (Login) :

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

e) Write this code : public class Class1 {


public double sum(Int16 a, Int16 b) {
return (a + b);
}
public double sub(Int16 a, Int16 b) {
return (a - b);
}
}
f) Double Click on button1 (sum) and write code :

Class1 c1 = new Class1();


Label1.Text =
c1.sum(Convert.ToInt16(TextBox1.Text),Convert.ToInt16(TextBox2.Text)).ToString();
g) Double click on button2 ( subtraction) and write this code :

Class1 c1 = new Class1();


Label1.Text =
c1.sub(Convert.ToInt16(TextBox1.Text),Convert.ToInt16(TextBox2.Text)).ToString();
h) Click ctrl + f5 to run and debugging the program.

2) Using Bin Directory :


a) Open Visual studio > file > new > project > Class Library (p3_class.cs) > add
b) Write code :

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 :

P3_class.Class1 c1 = new p3_class.Class1();


Label1.Text = c1.sum(Convert.ToInt16(TextBox1.Text),Convert.ToInt16(TextBox2.Text)).ToString();
h) Double click on button 2 and write code :

P3_class.Class1 c1 = new p3_class.Class1();


Label1.Text = c1.sub(Convert.ToInt16(TextBox1.Text),Convert.ToInt16(TextBox2.Text)).ToString();
i) Import your created library p3_class using (using) keyword.
j) Click ctrl + f5 to run and debugging the program.

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 :

HttpCookie ck = new HttpCookie("a.txt");


ck["ino"] = TextBox1.Text;
ck["inm"] = TextBox2.Text;
ck["ipr"] = TextBox3.Text;
ck["iqu"] = TextBox4.Text;
try {
ck["tp"] = (Convert.ToInt16(TextBox3.Text) * Convert.ToInt16(TextBox4.Text)).ToString();
}
catch { }
ck.Expires = DateTime.Now.AddSeconds(5);
Response.Cookies.Add(ck);
Response.Write("welcome to our website....");
5) Write this code to button 2 : Response.Redirect("another_page.aspx");
6) In another page write code in Page_Load function :

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.

1) Download/create image that take ‘Home’, ‘Product’, and ‘Services’


2) Open visual studio > file > new > web site> add new item
3) Right click on path > add existing item (or alt + shift + A).
4) Select this image and load into VS 2010.
5) Drag ImageMap to our design from left side bar (toolbox > standard)
6) Right side in Properties click on ImageUrl and add our image
7) In properties click on HotSopts and Add RectangleHotSpot/CircleHotSpot > right pixels using paint. And give NavigateUrl as new page
name. and click ok
8) Click ctrl + f5 to run and debugging the program.

8. USING ADROTATOR CONTROL, DISPLAY 3 IMAGES OF CAR AND WHEN USER CLICKS ON IT, OPEN WEBSITE OF IT. LOAD

THE ADVERTISEMENT DETAILS FROM THE XML.

1) Download/create 3 car images


2) Open visual studio > file > new > web site> add new item
3) Right click on path and click add existing item (or alt + shift + A).
4) Select 3 car images and load into VS 2010.
5) Drag button to our design from left side bar (toolbox > standard) and Ad Rotator.
6) Add new item > XML file > write code.
7) In design right click on AdRotator.
8) Right side in Properties click AdvertisementFile and load XML file, which you created.
9) Click ctrl + f5 to run and debugging the program.

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”.

4) Write code in ‘upload file button’ :


a) string s = Server.MapPath("img") + "/" + FileUpload1.FileName; // find image path and store in ‘s’

b) if (FileUpload1.HasFile) { //check existence of image in server

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

DirectoryInfo d1 = new DirectoryInfo(Server.MapPath("img")); // find image path and store in d1

FileInfo[ ] f1 = d1.GetFiles( ); //get files from d1 and make array f1

DataList1.DataSource = f1; //

DataList1.DataBind(); // bind data in datalist 1

b) This step is for datalist :


i) Click on datalist’s (>) arrow.
ii) Click on Edit templates.
iii) Drag image in item template from toolbox.
iv) Click image (>) and edit DataBindings.

v) Write this code : Eval("name","~/img/{0}")

vi) Click datalist (>) arrow and click End template editing.
6) Click ctrl + f5 to run and debugging the program.

10. CREATE A FORM TO DISPLAY TOTAL NUMBER USERS VISITED A WEBSITE.

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.

5) In Application_Start write this code : Application["cnt"] = 0;


6) In Session_Start write this code : Application["cnt"] = (int)Application["cnt"] + 1;
7) Click ctrl + f5 to run and debugging the program.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy