IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

Conflit entre 2 Onclick


Sujet :

ASP.NET

  1. #1
    Membre très actif
    Inscrit en
    Décembre 2006
    Messages
    205
    Détails du profil
    Informations forums :
    Inscription : Décembre 2006
    Messages : 205
    Par défaut Conflit entre 2 Onclick
    Bonjour;
    Voici le problème:
    J'ai sur mon master page un imagebutton qui permet de changer la redirection vers une autre page lorsqu'il est cliqué (événement Onclick).
    Sur le content page lié à ce master page, j'ai un formulaire, avec un bouton à valider (événement Onclick) pour envoyer ce dernier.
    Je n'arrive pas faire de redirection avec l'image bouton tant que le formulaire n'a pas été rempli et validé. Hors je souhaite laisser le choix à l'utilisateur de faire une redirection, sans forcément remplir et valider le formulaire.
    Je pense qu'il y a un conflit entre le Onclick de l'image button du masterpage et le button du content page.
    Ci-joint le code complet:
    1- frMasterPage.master:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="frMasterPage.master.cs" Inherits="frMasterPage" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <meta name="generator" content="Microsoft Visual Studio, see http://msdn.microsoft.com/vstudio/" />
        <meta name="Keywords" content="PrestigeConcepts, Widgets" />
        <meta name="Description" content="About PrestigeConcepts, Inc., it's widgets, employees and company" />
        <meta name="copyright" content="Copyright (c) 2008 PrestigeConcepts, Inc. All rights reserved." />
        <link href="/App_Themes/css-print.css" rel="stylesheet" type="text/css" media="print" />
        <link rel="shortcut icon" href="images/prestige.ico" />
        <title>PrestigeConcepts</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:SiteMapDataSource ID="SiteMapFra" runat="server" 
                ShowStartingNode="false" />
            <!--
    
    TOP INFORMTION
    -->
            <div id="top-information">
                <div>
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/images/logoprestige.jpg" 
                        Width="150px" />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:ImageButton ID="ImageButtonDrapeauEn" runat="server" 
                        ImageUrl="~/images/drapeauen.jpg" Width="30px" onclick="ImageButtonDrapeauEn_Click"/>
                        &nbsp;
                        <asp:ImageButton ID="ImageButtonDrapeauFr" runat="server" 
                        ImageUrl="~/images/drapeaufr.jpg" Width="30px" onclick="ImageButtonDrapeauFr_Click"/>
                 </div>
                <div id="top-information-home">
                    <a href="mailto:info@prestigeconcepts.fr">E-mail</a></div>
                <div id="top-information-phone">
                    tel: (+216)71 82 07 47 </div>
            </div>
            <!--
    
    TOP NAV
    
    -->
            <div class="none"><a href="#maincontent">skip to the main content area of this page</a></div>
            <div id="nav-main">
                           <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapFra" Orientation="Horizontal"
                    Width="500px" CssClass="menu-main" MaximumDynamicDisplayLevels="0" 
                               StaticSelectedStyle-CssClass="StaticSelectedStyle" >
    <StaticSelectedStyle CssClass="StaticSelectedStyle"></StaticSelectedStyle>
                           </asp:Menu>
                <div>
                    &nbsp;</div>
            </div>
            <a id="maincontent"></a>
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            </asp:ContentPlaceHolder>
            <!--
    
    FOOTER
    
    -->
            <div id="footer">
                Copyright &copy; 2008 PrestigeConcepts, Inc.
                <div>
                    &nbsp;</div>
            </div>
            
        </form>
    </body>
    </html>
    2- frMasterPage.master.cs
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    public partial class frMasterPage : System.Web.UI.MasterPage
    {
        protected void ImageButtonDrapeauFr_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            Server.Transfer("~/Fra/frDefault.aspx");
        }
        protected void ImageButtonDrapeauEn_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            Server.Transfer("~/Eng/Default.aspx");
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            SiteMapFra.SiteMapProvider = "Fra";
            SiteMapFra.DataBind();
        }
    }


    3- frContact.aspx:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    <%@ Page Language="C#" MasterPageFile="~/Fra/frMasterPage.master" AutoEventWireup="true" CodeFile="frContact.aspx.cs" Inherits="frContact" Title="Prestige Concepts Inc: Contact" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    
    
        <div id="content-container-three-column">
            <!--
    
      CONTENT SIDE 1 COLUMN
    
      -->
            <div id="content-side1-three-column">
                <ul class="list-of-links">
                    <li class="current"><a href="frContact.aspx">Contact</a></li>
                    <li><a href="frDefault.aspx">Accueil</a></li>
                    <li><a href="frProducts.aspx">Produits</a></li>
                      <li><a href="frPartners.aspx">Partenaires</a></li>
                      <li><a href="frReferences.aspx">Réferences</a></li>
                    <li><a href="frAbout.aspx">A propos</a></li>
                    <li><a href="frTestimonials.aspx">Témoignages</a></li>
                </ul>
            </div>
            <!--
    
      CENTER COLUMN
    
      -->
            <div id="content-main-three-column">
                <span id="heading">Contact Us</span>
                <hr />
                <h3>
                    Global Headquaters
                </h3>
                <p>
                    Prestige concepts<br />
                    LL1/9-Kortoba Riadh El Andalous<br />
                    2058 Ariana Tunis Tunisie
                </p>
                <p>
                    tel: (+216)71 82 07 47 / (+216)71 82 07 46
                    
                    <br />
                    fax: (+216)71 82 07 48
                </p>
                <a href="mailto:info@prestigeconcepts.com">info@prestigeconcepts.com</a><br />
               
                <p>
                </p>
                <br />
      
                <asp:Panel ID="Panel1" runat="server" Height="526px" BorderStyle="Dotted" BorderColor="gray"
                    Width="350px" >
                    <table>
                        <caption>
                            <br />
                            <tr>
                                <td style="width: 100px">
                                    Company</td>
                                <td style="width: 100px">
                                    <asp:TextBox ID="txtCompany" runat="server" Width="175px"></asp:TextBox>
                                </td>
                                <td style="width: 100px">
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                                        ControlToValidate="txtCompany" ErrorMessage="Please enter your company name">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 100px">
                                    Name</td>
                                <td style="width: 100px">
                                    <asp:TextBox ID="txtName" runat="server" Width="175px"></asp:TextBox>
                                </td>
                                <td style="width: 100px">
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                        ControlToValidate="txtName" ErrorMessage="Please enter your name">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 100px">
                                    Email</td>
                                <td style="width: 100px">
                                    <asp:TextBox ID="txtEmail" runat="server" Width="175px"></asp:TextBox>
                                </td>
                                <td style="width: 100px">
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                        ControlToValidate="txtEmail" ErrorMessage="Please enter your email address">*</asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                        ControlToValidate="txtEmail" 
                                        ErrorMessage="Please enter a valid email (xxx@yyy.zzz)" 
                                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 100px">
                                    Phone
                                </td>
                                <td style="width: 100px">
                                    <asp:TextBox ID="txtPhone" runat="server" Width="175px"></asp:TextBox>
                                </td>
                                <td style="width: 100px">
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                        ControlToValidate="txtPhone" ErrorMessage="Please enter your phone number">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 100px; height: 116px;">
                                    Message<span style="font-size: 10pt">*</span>
                                    <br />
                                </td>
                                <td style="width: 100px; height: 116px;">
                                    <asp:TextBox ID="txtMessage" runat="server" Height="106px" TextMode="MultiLine"></asp:TextBox>
                                </td>
                                <td style="width: 100px; height: 116px;">
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                        ControlToValidate="txtMessage" ErrorMessage="Please enter a message">*</asp:RequiredFieldValidator>
                                    <asp:CustomValidator ID="CustomValidator1" runat="server" 
                                        ControlToValidate="txtMessage" 
                                        ErrorMessage="No more than 1000 characters, no less than 20 characters" 
                                        OnServerValidate="CustomValidator1_ServerValidate">*</asp:CustomValidator>
                                </td>
                            </tr>
                        </caption>
                    </table>
                   
                   <hr />
                   <asp:Button ID="btnValidate" runat="server" Text="Validate" Width="61px" 
                        style="left: 156px; position: relative; top: 10px" 
                        OnClick="btnValidate_Click" />&nbsp;<br />
                    <br />
                    <br />
                    <span style="font-size: 7pt">All the fields are compulsory
                        <br />
                        * = Maximum 1000 characters, minimum 20 characters<br />
                        <br />
                        <asp:Label ID="lblError" runat="server"></asp:Label>
                    <br />
                    <br />
                    <br />
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" Height="56px" 
                        Width="342px" />
                    </span></asp:Panel>
                &nbsp;
            </div>
            <!-- END MAIN COLUMN -->
            <!--
    
      CONTENT SIDE 2 COLUMN
    
      -->
            <div id="content-side2-three-column">
                <span id="subheading">Prestige Concepts listening you.</span>
                <p>
                <br />
                <br />
                    If you have any question, don't hesitate to contact us. A dynamic and reactive 
                    team will answer you quickly.&nbsp;</div>
            <div class="clear">
                
                </div>
                
        </div>
    </asp:Content>
    4- frContact.aspx.cs:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
     
    using System;
    using System.Web.Mail;
     
    public partial class frContact : System.Web.UI.Page
    {
     
        protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            if ((txtMessage.Text.Length < 20) || (txtMessage.Text.Length > 1000))
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }
     
     
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtName.Text = "";
                txtEmail.Text = "";
                txtCompany.Text = "";
                txtPhone.Text = "";
                txtMessage.Text = "";
     
            }
        }
     
        protected void btnValidate_Click(object sender, EventArgs e)
        {
            MailMessage email = new MailMessage();
            email.From = "site@prestigeconcepts.fr";
            email.To = "info@prestigeconcepts.fr";
            email.Body =
                "Name :"
                + txtName
                + "\r\n"
                + "Email :"
                + txtEmail
                + "\r\n"
                + "Company: "
                + txtCompany.Text
                + "\r\n"
                + "Phone : "
                + txtPhone.Text
                + "\r\n"
                + "Message : "
                + txtMessage.Text;
            email.Priority = MailPriority.High;
     
            SmtpMail.SmtpServer = "smtp.planet.tn";
     
            try
            {
                SmtpMail.Send(email);
                lblError.Text = "Message envoyé avec succès";
     
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
     
        }
     
    }
    Merci si vous pouvez m'aider à trouver une solution.

  2. #2
    Rédacteur
    Avatar de lutecefalco
    Profil pro
    zadzdzddzdzd
    Inscrit en
    Juillet 2005
    Messages
    5 052
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : zadzdzddzdzd

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 052
    Par défaut
    Mets CauseValidation = "false" sur le bouton qui sert à faire la redirection

  3. #3
    Membre très actif
    Inscrit en
    Décembre 2006
    Messages
    205
    Détails du profil
    Informations forums :
    Inscription : Décembre 2006
    Messages : 205
    Par défaut
    Ta solution marche.
    Merci.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Conflit entre javascript et script ASP
    Par Mvu dans le forum ASP
    Réponses: 2
    Dernier message: 22/02/2005, 16h28
  2. Possibles conflits entre GL, GLAUX et GLUT
    Par barthelv dans le forum GLUT
    Réponses: 1
    Dernier message: 19/11/2004, 12h31
  3. Conflit entre bases de données
    Par BRODU dans le forum Bases de données
    Réponses: 4
    Dernier message: 18/10/2004, 11h40
  4. conflit entre couleurs
    Par khayyam90 dans le forum OpenGL
    Réponses: 2
    Dernier message: 03/07/2004, 18h00
  5. [Technique] Conflits entre plusieurs requêtes
    Par Neowile dans le forum Décisions SGBD
    Réponses: 3
    Dernier message: 24/03/2003, 09h37

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo