Professional Documents
Culture Documents
Practical Solution Bhshah-Ii
Practical Solution Bhshah-Ii
12 Create following web page using File Upload Control. Provide following restrictions on it.
1. If user doesn’t select a file and press submit button then message should be display “Please
select file to upload...” in red color.
2. It allows only Image file with extension .jpg or .jpeg
3. Max file size is 2 MB to upload.
1
PREPARED BY: PROF. BHAUMIK SHAH
ASP.NET PRACTICAL SOLUTION
PREPARED BY: PROF. BHAUMIK SHAH
}
}
else
{
Label1.Text = "Please select the File....";
Label1.ForeColor = System.Drawing.Color.Red;
}
}
}
13 Create a website that displays two advertisements alternately. When the user clicks on one of
the advertisements, he/she is redirected to “www.amazon.com”, and the other advertisement
redirects the user to “www.sony.com”. The advertisement should be centred horizontally and should
cover 60% of the width of the screen. Its height should be 80 units. The width of the border should be 5
units.
Code: XMLFile.xml
Code: Prg13.aspx
<body>
<form id="form1" runat="server">
<div>
<table width="80%" align="center">
<tr>
<td align="center">
<h2>AdRotator Demo</h2>
</td>
</tr>
<tr>
<td align="center">
<asp:AdRotator ID="AdRotator1" runat="server"
AdvertisementFile="~/XMLFile.xml"
BorderWidth="5px" Height="80px" Width="100px" />
</td>
</tr>
</table>
</div>
</form>
</body>
14 Program using ASP.NET Validation controls. Create the application that accepts name, password, age,
email id, and user id. All the information entry is compulsory. Password should be reconfirmed. Age
should be within 21 to 30. Email id should be valid. User id should have at least a capital letter and digit
as well as length should be between 7 and 20 characters.
3
PREPARED BY: PROF. BHAUMIK SHAH
ASP.NET PRACTICAL SOLUTION
PREPARED BY: PROF. BHAUMIK SHAH
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
4
PREPARED BY: PROF. BHAUMIK SHAH
ASP.NET PRACTICAL SOLUTION
PREPARED BY: PROF. BHAUMIK SHAH
Properties to be set
16 Develop following program using Textbox, ImageButton and calendar control. When user clicks on
calendar ImageButton, Calendar should be displayed. Selected date should be displayed in a textbox.
5
PREPARED BY: PROF. BHAUMIK SHAH
ASP.NET PRACTICAL SOLUTION
PREPARED BY: PROF. BHAUMIK SHAH
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (Calendar1.Visible)
{
Calendar1.Visible = false;
}
else
{
Calendar1.Visible = true;
}
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
TextBox1.Text = Calendar1.SelectedDate.ToString("d");
}
}
17 By using a PlaceHolder control dynamically add Image by clicking Add Image button.
6
PREPARED BY: PROF. BHAUMIK SHAH
ASP.NET PRACTICAL SOLUTION
PREPARED BY: PROF. BHAUMIK SHAH
Design Output
18 Create Master Page with menu control and content place holder.
Creating a MasterPage
7
PREPARED BY: PROF. BHAUMIK SHAH
ASP.NET PRACTICAL SOLUTION
PREPARED BY: PROF. BHAUMIK SHAH
19 Count number of clicks when user press Count Clicks button in a Textbox using ViewState.
}
protected void Button1_Click(object sender, EventArgs e)
{
if (ViewState["clicks"] != null)
{
c = (int)ViewState["clicks"] + 1;
}
TextBox1.Text = c.ToString();
ViewState["clicks"] = c;
}
protected void Button2_Click(object sender, EventArgs e)
{
}
8
PREPARED BY: PROF. BHAUMIK SHAH
ASP.NET PRACTICAL SOLUTION
PREPARED BY: PROF. BHAUMIK SHAH
}
20 Send the information from one page to another page using QueryString.
Page 1 Page 2
Code of Page 1
21 Create a Form that receives the user name, address, date, nationality, country preferred for working and
skill sets from the user and stores the user name on the client side using cookies. The country preferred
data should appear in a dropdownlist, whereas others should be entered in a textbox. By Clicking
submit button all information should be display on another web page. Store cookies on client machine
for 10Days.
9
PREPARED BY: PROF. BHAUMIK SHAH
ASP.NET PRACTICAL SOLUTION
PREPARED BY: PROF. BHAUMIK SHAH
cookie1.Expires = DateTime.Now.AddDays(10);
Response.Cookies.Add(cookie1);
Response.Redirect("next_page.aspx");
}
Code of next_page.aspx
}
}
10
PREPARED BY: PROF. BHAUMIK SHAH
ASP.NET PRACTICAL SOLUTION
PREPARED BY: PROF. BHAUMIK SHAH
11
PREPARED BY: PROF. BHAUMIK SHAH