Académique Documents
Professionnel Documents
Culture Documents
net
Le contrôle image
imgDefault.ImageUrl = "Images/Pic.png";
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"runat="server"ControlToValidate="txtNom"
Display="Dynamic" ErrorMessage="le champ nom est obligatoir
!">*</asp:RequiredFieldValidator>
Validation du champ jour de : la valeur doit être comprise ente 26/03/2012 et 31/03/2012
<asp:RegularExpressionValidator ID="RegularExpressionValidator2"
runat="server" ControlToValidate="txtDateNaissance"
ErrorMessage="Date de naissance invalide !"
ValidationExpression="^(((0[1-
9]|[12]\d|3[01])\/(0[13578]|1[02])\/((1[6- 9]|[2-
9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((1[6-9]|[2-
9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((1[6-9]|[2-
9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)
(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$"
>!</asp:RegularExpressionValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="txtEmail" Display="Dynamic"
ErrorMessage="Le champ email n'est pas valide !"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*">!</asp:RegularExpressionValidator>
//btnAffiche_Click
Response.Redirect("Default2.aspx?Nom=" +
Server.UrlEncode(txtNom.Text));
// Page_Load
lblNom.Text = Request.QueryString["Nom"];
Les Cookies
//btnAffiche_Click
Response.Cookies["MonCookie"].Value = txtNom.Text ;
Response.Cookies["MonCookie"].Expires = new DateTime(2012, 03, 24);
Response.Redirect("Defalut2.aspx");
// Page_Load
lblNom.Text = Request.Cookies["MonCookie"].Value ;
//Button1_Click
Session["TestVariable"] = TextBox1.Text;
// Button2_Click
TextBox2.Text = Session["TestVariable"].ToString();
Les variables d'application
//Button1_Click
Application.Lock();
Application["TestVariable"] = TextBox1.Text;
Application.UnLock();
// Button2_Click
TextBox2.Text = Application["TestVariable"].ToString();
TextBox1.Text = Request.Cookies["login"].Value;
if (Response.Cookies["pw"] != null){
Response.Redirect("index.aspx");}}}}
Response.Cookies["login"].Value = TextBox1.Text;
if (CheckBox1.Checked)
{Response.Cookies["pw"].Value = TextBox2.Text;
Response.Redirect("index.aspx");}}}}
FileUpload
FileUpload1.SaveAs("D:\\upload\\" + FileUpload1.FileName);
Grid View
Ajouter
if (e.CommandName == "ajouter")
{
cnx.Open();
}
Annuler
if (e.CommandName == "annuler")
{
gViewPrd.EditIndex = -1;
remlire();
}
supprimer
else if (e.CommandName == "DeletePrd")
{
cnx.Open();
SqlCommand cmdDelete = new SqlCommand("DELETE FROM typeProduit WHERE idtype =
@idtype", cnx);
cmdDelete.Parameters.Add("@idtype", SqlDbType.Int);
cmdDelete.Parameters["@idtype"].Value =
((Label)gViewPrd.Rows[rowIndex].FindControl("labelidtype")).Text;
cmdDelete.ExecuteNonQuery();
remlire();
modifier
if (e.CommandName == "modifier")
{
gViewPrd.EditIndex = rowIndex;
remlire();
}
Mise a jour
if (e.CommandName == "Update")
{
cnx.Open();
cmd = new SqlCommand(@"update typeProduit set typeProduit =
@typeProduit, TVA = @TVA where IdType = @IdType", cnx);
cmd.Parameters.Add("@IdType", SqlDbType.Int);
cmd.Parameters.Add("@typeProduit", SqlDbType.Char);
cmd.Parameters.Add("@TVA", SqlDbType.Int);
cmd.Parameters["@IdType"].Value =
((Label)gViewPrd.Rows[rowIndex].FindControl("labelidtype")).Text;
cmd.Parameters["@typeProduit"].Value =
((TextBox)gViewPrd.Rows[rowIndex].FindControl("textBtypeProduit")).Text;
cmd.Parameters["@TVA"].Value =
((TextBox)gViewPrd.Rows[rowIndex].FindControl("textBTVA")).Text;
cmd.ExecuteNonQuery();
gViewPrd.EditIndex = -1;
remlire();
}