Professional Documents
Culture Documents
Zgjidhje
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"
Inherits="Leksion4.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
UserName
</td>
<td>
<asp:TextBox ID="UserNameTextBox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
PassWord
</td>
<td>
<asp:TextBox ID="PassWordTextBox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="LogInButton" runat="server" Text="LogIn"
OnClick="LogInButton_Click"/></td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="ErrorLabel" runat="server"></asp:Label>
</td>
</tr>
</table>
1
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Leksion4
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
2
Zgjidhje
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Feeback Form:
<table>
<tr>
<td>
Emri Mbiemri i Studentit:
</td>
<td>
<asp:TextBox ID="NameTextBox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Gjinia:
</td>
<td>
<asp:RadioButtonList ID="GenderRadioButtonList"
runat="server"></asp:RadioButtonList>
</td>
</tr>
<tr>
<td>
Kurset:
</td>
<td>
<asp:DropDownList ID="CoursesDropDownList"
runat="server"></asp:DropDownList>
3
</td>
</tr>
<tr>
<td>
Teknika e Mesimdhenies:
</td>
<td>
<asp:RadioButtonList ID="TechnicRadioButtonList"
runat="server"></asp:RadioButtonList>
</td>
</tr>
<tr>
<td>
Sugjerime:
</td>
<td>
<asp:TextBox ID="SuggestionTextBox" runat="server"
TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="SendButton" runat="server" Text="Dergo te dhenat"
OnClick="SendButton_Click"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label runat="server" ID="ResultLabel"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Leksion4
{
public partial class SurveyForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
FillGender();
FillCourses();
FillEvaluations();
}
}
4
private void FillGender()
{
GenderRadioButtonList.Items.Clear();
ListItem itemM = new ListItem();
itemM.Text = "Mashkull";
itemM.Value = "M";
ListItem itemF = new ListItem();
itemF.Text = "Femer";
itemF.Value = "F";
GenderRadioButtonList.Items.Add(itemM);
GenderRadioButtonList.Items.Add(itemF);
}
private void FillCourses()
{
CoursesDropDownList.Items.Clear();
CoursesDropDownList.Items.Add( new ListItem("ASP-XML", "ASP-XML"));
CoursesDropDownList.Items.Add(new ListItem("DotNET", "DotNET"));
CoursesDropDownList.Items.Add(new ListItem("JavaPro", "JavaPro"));
CoursesDropDownList.Items.Add(new ListItem("Unix", "Unix"));
CoursesDropDownList.Items.Add(new ListItem("C", "C"));
CoursesDropDownList.Items.Add(new ListItem("C++", "C++"));
}
private void FillEvaluations()
{
TechnicRadioButtonList.Items.Clear();
TechnicRadioButtonList.Items.Add(new ListItem("Shkelqyeshem", "4"));
TechnicRadioButtonList.Items.Add(new ListItem("Mesatare", "3"));
TechnicRadioButtonList.Items.Add(new ListItem("Mire", "2"));
TechnicRadioButtonList.Items.Add(new ListItem("Dobet", "1"));
5
this.ResultLabel.Text += " faleminderit per vleresimin ";
}
else
{
this.ResultLabel.Text = "Kujdes Fusha Emri eshte bosh!";
this.ResultLabel.ForeColor = System.Drawing.Color.Red;
this.NameTextBox.BorderColor= System.Drawing.Color.Red;
return;
}
this.NameTextBox.BorderColor = System.Drawing.Color.Black;
if (TechnicRadioButtonList.SelectedValue != string.Empty)
{
this.ResultLabel.Text += TechnicRadioButtonList.SelectedItem.Text;
this.ResultLabel.Text += " qe keni dhene mbi kursin ";
}
else
{
this.ResultLabel.Text = "Kujdes duhet te perzgjidhni nje kurs!";
this.ResultLabel.ForeColor = System.Drawing.Color.Red;
this.TechnicRadioButtonList.BackColor = System.Drawing.Color.Red;
return;
}
this.TechnicRadioButtonList.BackColor = System.Drawing.Color.Transparent;
if (CoursesDropDownList.SelectedIndex>=0)
{
this.ResultLabel.Text += CoursesDropDownList.SelectedValue;
}
else
{
this.ResultLabel.Text = "Kujdes duhet te perzgjidhni nje kurs!";
this.ResultLabel.ForeColor = System.Drawing.Color.Red;
this.CoursesDropDownList.BackColor = System.Drawing.Color.Red;
return;
}
this.CoursesDropDownList.BackColor = System.Drawing.Color.Transparent;
}
}
}
ListBox do te perdoret per Produktet e vlefshme te nje dyqani. TextBox dhe nje nga kontrollet Label do
te perdoret per vendosjen e tekstit “Vendos Sasine:” dhe vleren perkatese. Ne momentin qe
perdoruesi klikon mbi button do te shfaqet imazhi I produktit, si dhe ne kontrollin Label te mbetur
afishohet vlera totale mbi baze te produktit te zgjedhur.
6
Zgjidhje
Skedari : SampleStyleSheet.css
body {
}
.table-td{
padding:5px;
font-size:small;
color:brown;
width:50%
}
.labelS
{
color:orangered;
font-size:medium;
}
.buttonS
{
border-color:blue;
background-color:coral;
7
font-size:small;
color:antiquewhite;
//position:center;
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" href="SampleStyleSheet.css" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
Dyqani ABC
<hr />
<table>
<tr >
<td class="table-td">Lista e Produkteve</td>
<td class="table-td">
<asp:DropDownList ID="ProductDropDownList"
runat="server"></asp:DropDownList>
</td>
</tr>
<tr>
<td class="table-td">Sasia: </td>
<td class="table-td">
<asp:TextBox ID="AmountTextBox" runat="server"></asp:TextBox> </td>
</tr>
<tr>
<td class="table-td" colspan="2">
</td>
</tr>
<tr>
<td class="table-td" colspan="2">
<asp:Label runat="server" ID="ResultLabel" CssClass="labelS"
> </asp:Label>
<hr /></td>
</tr>
<tr>
<td class="table-td" colspan="2">
</td>
</tr>
</table>
8
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Leksion4
{
public partial class ShopForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
FillProductList();
}
}
private void FillProductList()
{
}
else
{
this.AmountTextBox.BorderColor = System.Drawing.Color.Black;
double price = Convert.ToDouble(ProductDropDownList.SelectedValue);
double total = price * amount;
ProductImg.ImageUrl = "images\\image" + ProductDropDownList.SelectedIndex
+ ".jpg";
ResultLabel.Text = "Totali: "+total;
}
}
}
9
4. Te ndertohet forma me poshte ne Asp.Net
Zgjidhje
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ActionNrForm.aspx.cs"
Inherits="Leksion4.ActionNrForm" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Kryej veprimet
<table>
<tr>
<td >
<asp:RadioButtonList ID="ActionRadioButtonList"
runat="server"></asp:RadioButtonList>
</td>
<td></td>
</tr>
<tr>
<td>
<asp:TextBox ID="Nr1TextBox" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="Nr2TextBox" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
10
<td>
<asp:Button ID="CalculateButton" runat="server" Text="Llogarit"
OnClick="CalculateButton_Click"/></td>
<td>
<asp:Label ID="ResultLabel" runat="server" Text=""></asp:Label></td>
</tr>
<tr>
<td> <asp:Button ID="ClearButton" runat="server" Text="Pastro Rezultatin"
OnClick="ClearButton_Click" /></td>
<td></td>
</tr>
</table>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Leksion4
{
public partial class ActionNrForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
FillActionList();
}
}
private void FillActionList()
{
ActionRadioButtonList.Items.Clear();
ActionRadioButtonList.Items.Add( new ListItem("Mbledhje", "1"));
ActionRadioButtonList.Items.Add(new ListItem("Zbritje", "2"));
ActionRadioButtonList.Items.Add(new ListItem("Shumezim", "3"));
ActionRadioButtonList.Items.Add(new ListItem("Pjesetim", "4"));
}
11
else
selectedItem = 0;
switch (selectedItem)
{
case 1:
result = nr1 + nr2;
break;
case 2:
result = nr1 - nr2;
break;
case 3:
result = nr1 * nr2;
break;
case 4:
if (nr2 != 0)
result = nr1 + nr2;
else
{
ResultLabel.Text = "Kujdes: Pjesetuesi eshte 0";
return;
}
break;
default:
ResultLabel.Text = "Nuk keni perzgjedhur asnje veprim!";
break;
}
ResultLabel.Text +=string.Format("Rezultati eshte:{0}",result);
}
else
{
ResultLabel.Text = "Nuk mund te kryhet konvertimi ne numra!";
}
}
12
e. Fusha Password te paraqitet si ne figure.
13