2016-09-26 6 views
0

J'ai un gridview avec la colonne "View" ID = "lnkViewContact". Au clic de ce lien, l'inscription modalpopupextender sera affichée. Cette popup est similaire pour toutes les lignes. Mais quand je l'exécute l'erreur que je reçois est "Impossible de trouver le contrôle lnkViewContact". Comment cela peut-il être résolu? une alternative est en utilisant l'événement Onclick sur le clic de lien, mais je ne veux pas faire une publication pour ouvrir le Popupextender. Voici mon code:Gridview Impossible de trouver le contrôle pour modalpopupextender

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
 
       <ContentTemplate> 
 
        <asp:Panel ID="pnlNoData" runat="server" align="center" Visible="false" Style="height: 300px; 
 
         width: auto;"> 
 
         <h1 style="font-variant: normal; font-family: Times New Roman; font-size: 1.8em; 
 
          margin-left: 15px; font-weight: lighter; color: Green; margin-top: 100px;"> 
 
          Refine your search.</h1> 
 
         <h1 style="font-variant: normal; font-family: Times New Roman; font-size: 1.8em; 
 
          margin-left: 15px; font-weight: lighter; color: Green; margin-left: 100px; margin-right: 100px;"> 
 
          Not finding suitable candidates. </h1> 
 
         <cc1:ModalPopupExtender ID="mp3" runat="server" PopupControlID="pnlJobPost" BehaviorID="bvJobPost" 
 
          TargetControlID="lnkPostJobReq" BackgroundCssClass="mBackground" CancelControlID="btnClose"> 
 
         </cc1:ModalPopupExtender> 
 
         <asp:LinkButton ID="lnkPostJobSignUp" Text="Sign Up and Post Job" Font-Size="Medium" 
 
          runat="server" OnClick="SignUp" Visible="false"></asp:LinkButton> 
 
         <asp:LinkButton ID="lnkPostJobReq" Text="Post Job Requirement" Font-Size="Medium" 
 
          runat="server"></asp:LinkButton> 
 
        </asp:Panel> 
 
        <asp:GridView ID="grdSearchResult" runat="server" DataKeyNames="SeekerEmail_Id, Extension" 
 
         OnRowDataBound="OnRowDataBound" AutoGenerateColumns="False" BorderWidth="1px" 
 
         BackColor="White" CellPadding="5" BorderStyle="None" BorderColor="Gray" GridLines="Both" 
 
         Width="100%"> 
 
         <FooterStyle ForeColor="Black" BackColor="White"></FooterStyle> 
 
         <PagerStyle ForeColor="Black" HorizontalAlign="Center" BackColor="White"></PagerStyle> 
 
         <HeaderStyle ForeColor="White" Font-Bold="True" BackColor="Green"></HeaderStyle> 
 
         <Columns> 
 
          <asp:BoundField HeaderText="Job Skills" DataField="Primary_Skill" SortExpression="Primary_Skill" 
 
           ItemStyle-Width="35%" ItemStyle-HorizontalAlign="Center" ItemStyle-Wrap="true" 
 
           ItemStyle-CssClass="grdSearchResultbreakword"></asp:BoundField> 
 
          <asp:BoundField HeaderText="Resume Title" DataField="Resume_Title" SortExpression="Resume_Title" 
 
           ItemStyle-HorizontalAlign="Center" ItemStyle-Wrap="true" ItemStyle-Width="30%" 
 
           ItemStyle-CssClass="grdSearchResultbreakword"></asp:BoundField> 
 
          <asp:BoundField HeaderText="Exp (Years)" DataField="Experience" SortExpression="Experience" 
 
           ItemStyle-HorizontalAlign="Center"></asp:BoundField> 
 
          
 
          <asp:TemplateField HeaderText="Contact Details Email/Mobile" ItemStyle-HorizontalAlign="Center" 
 
           ItemStyle-Width="12%"> 
 
           <ItemTemplate> 
 
            <asp:LinkButton ID="lnkViewContact" Text="View" runat="server"></asp:LinkButton> 
 
           </ItemTemplate> 
 
          </asp:TemplateField> 
 
          <asp:TemplateField HeaderText="Contact Details Email/Mobile" ItemStyle-HorizontalAlign="Center" 
 
           ItemStyle-Width="15%"> 
 
           <ItemTemplate> 
 
            <asp:Label ID="lblContact" ForeColor="DarkOrange" runat="server" Text='<%# Eval("SeekerEmail_Id").ToString() +"/"+ Eval("Contact_Number").ToString() %>' 
 
             Style="word-wrap: normal; word-break: break-all; cursor: default;"></asp:Label> 
 
           </ItemTemplate> 
 
          </asp:TemplateField> 
 
          <asp:TemplateField HeaderText="Download Resume" ItemStyle-HorizontalAlign="Center"> 
 
           <ItemTemplate> 
 
            <asp:LinkButton ID="lnkDown" Text="Download" runat="server" OnClick="SignUp"></asp:LinkButton> 
 
           </ItemTemplate> 
 
          </asp:TemplateField> 
 
          
 
         </Columns> 
 
         <SelectedRowStyle ForeColor="White" Font-Bold="True" BackColor="#008A8C"></SelectedRowStyle> 
 
         <RowStyle ForeColor="Black" BackColor="White"></RowStyle> 
 
         <SortedAscendingCellStyle BackColor="#F1F1F1" /> 
 
         <SortedAscendingHeaderStyle BackColor="#0000A9" /> 
 
         <SortedDescendingCellStyle BackColor="#CAC9C9" /> 
 
         <SortedDescendingHeaderStyle BackColor="#000065" /> 
 
        </asp:GridView> 
 
        <asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton> 
 
        <cc1:ModalPopupExtender ID="mp1" BehaviorID="behaviorIDmp1" runat="server" PopupControlID="Panl1" 
 
         TargetControlID="lnkViewContact" CancelControlID="btnCancel" DropShadow="true" BackgroundCssClass="modalBackground"> 
 
        </cc1:ModalPopupExtender> 
 
        <asp:Panel ID="Panl1" runat="server" CssClass="modalPopup" align="center" Style="display: none; 
 
         height: 400px;" DefaultButton="btnRegister"> 
 
         <%--<h1 style="font-variant: normal; font-family: Comic Sans MS; font-size: 1.5em; font-weight: lighter; 
 
        margin-top: 2px; margin-bottom: 2px; text-align: center; color: Blue;"> 
 
        SIGN UP</h1>--%> 
 
         
 
         <asp:Label ID="lblEmailId" runat="server" ForeColor="Black" Text="Email address" 
 
          Style="font-weight: bold; display: block; text-align: left; margin-left: 45px; 
 
          margin-top: 10px;"></asp:Label> 
 
         <asp:TextBox ID="txtEmailAddress" runat="server" class="txtFirstName" MaxLength="100" 
 
          name="email" TabIndex="3" value="" /><br /> 
 
         <asp:RequiredFieldValidator EnableClientScript="true" ID="reqEmailAdress" runat="server" 
 
          ValidationGroup="modal" ControlToValidate="txtEmailAddress" ErrorMessage="Email Address Required" 
 
          Display="Dynamic" Style="color: Red;" /> 
 
         <asp:RegularExpressionValidator ID="regEmailAddress" runat="server" ErrorMessage="Not Valid Email ID" 
 
          ValidationGroup="modal" Display="Dynamic" ControlToValidate="txtEmailAddress" 
 
          ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"> 
 
         </asp:RegularExpressionValidator> 
 
         <asp:Label ID="lblContactNumber" runat="server" ForeColor="Black" Text="Contact Number(Don't prefix 0 or +91)" 
 
          Style="font-weight: bold; display: block; text-align: left; margin-left: 45px;"></asp:Label> 
 
         <asp:TextBox ID="txtContactNumber" runat="server" class="txtFirstName" MaxLength="15" 
 
          name="contact" TabIndex="6" value="" /><br /> 
 
         <asp:RequiredFieldValidator EnableClientScript="true" ID="reqContactNumber" runat="server" 
 
          ValidationGroup="modal" ControlToValidate="txtContactNumber" ErrorMessage="Contact Number Required" 
 
          Display="Dynamic" Style="color: Red;" /> 
 
         <asp:RegularExpressionValidator ID="regContactNumber" runat="server" ControlToValidate="txtContactNumber" 
 
          ValidationGroup="modal" Text="Only 10 digit valid contact number is valid." ValidationExpression="[0-9]{10}" 
 
          Style="color: Red;" Display="Dynamic"></asp:RegularExpressionValidator> 
 
         <asp:Button ID="btnRegister" ValidationGroup="modal" class="btnempregsubmit" runat="server" 
 
          Text="Save" OnClick="Register" CausesValidation="false" /> 
 
         <br /> 
 
         <asp:HyperLink ID="btnCancel" runat="server" Text="Cancel" CssClass="btnClosePopup">Close</asp:HyperLink> 
 
        </asp:Panel> 
 
       </ContentTemplate> 
 
       <Triggers> 
 
        <asp:AsyncPostBackTrigger ControlID="grdSearchResult" /> 
 
        <asp:AsyncPostBackTrigger ControlID="btnRegister" /> 
 
       </Triggers> 
 
      </asp:UpdatePanel>

Répondre

1

Il est un peu confus quand vous avez mentionné « une alternative à l'aide d'événement onclick sur le lien clic, mais je ne veux pas faire un postback pour ouvrir le Popupextender . 'Si vous voulez un événement OnClick, vous devrez effectuer une publication. Voici une suggestion.

..... Cette pièce est votre code ....

<asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton> 
 
        <cc1:ModalPopupExtender ID="mp1" BehaviorID="behaviorIDmp1" runat="server" PopupControlID="Panl1" 
 
         TargetControlID="lnkViewContact" CancelControlID="btnCancel" DropShadow="true" BackgroundCssClass="modalBackground"> 
 
        </cc1:ModalPopupExtender>

.... Remplacer cette ......

<asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton> 
 
        <cc1:ModalPopupExtender ID="mp1" BehaviorID="behaviorIDmp1" runat="server" PopupControlID="Panl1" 
 
         TargetControlID="lnkFake" CancelControlID="btnCancel" DropShadow="true" BackgroundCssClass="modalBackground"> 
 
        </cc1:ModalPopupExtender>

Et sur le OnCl code d'événement ick derrière, faire cela pour montrer la pop up

mp1.Show()

+0

Oui, votre solution fonctionne mais le problème auquel je suis confronté avec onclick est qu'il prend trop de temps pour afficher le popup, peut-être parce qu'il rafraichit tout le gridview qui porte beaucoup de lignes. Et je veux seulement montrer une même fenêtre d'inscription pour chaque lien de la ligne gridview. Y at-il un autre moyen que je peux afficher la popup? – Anurag

+0

A ma connaissance l'événement OnClick est dans le même panneau de mise à jour donc il sera toujours sauvegardé. Désolé je ne pouvais pas aider à ce sujet. – Eaint

0

Le linkButton dans un GridView ne peut pas être défini comme un TargetControlID de ModalPopupExtender parce que lors de l'exécution de l'ID de linkbutton changera dynaically. Le travail autour est d'utiliser l'événement Onclick de LinkButton et comme dans mon cas s'il y a une validation dans modalpopupextender, alors validez les contrôles côté serveur.