locked
Gridview having column link for Signup with Modalpopupextender not working. RRS feed

  • Question

  • User-1659672931 posted

    I have a gridview with colun "View" ID= "lnkViewContact". On click of this link signup modalpopupextender will be displayed. This popup is same for all the rows. But when I am running it the error I am getting is "Could not found control lnkViewContact". How can I resolve this. Below is my code:

     <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. Post Job skill set here and we will search candidates
                                for you and update.</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="Current Location" ItemStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:Label ID="lblLocation" runat="server" ToolTip='<%# Eval("Location")%>' Text='<%# Eval("Location").ToString().Shorten(30) %>'
                                            Style="word-wrap: normal; word-break: break-all; cursor: default;"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <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>
                                <asp:TemplateField HeaderText="Download Resume" ItemStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:UpdatePanel ID="lnkdownldUpdate" runat="server">
                                            <ContentTemplate>
                                                <asp:LinkButton ID="lnkDownload" Text='Download' CommandArgument='<%# Eval("Resume_Title") %>'
                                                    OnClick="DownloadFile" runat="server" Style="word-wrap: normal; word-break: break-all;
                                                    cursor: pointer;"></asp:LinkButton>
                                            </ContentTemplate>
                                            <Triggers>
                                                <asp:PostBackTrigger ControlID="lnkDownload" />
                                            </Triggers>
                                        </asp:UpdatePanel>
                                    </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="lblFirstName" runat="server" ForeColor="Black" Text="Name" Style="font-weight: bold;
                                display: block; text-align: left; margin-left: 45px; margin-top: 10px;"></asp:Label>
                            <asp:TextBox ID="txtFirstName" runat="server" class="txtFirstName" MaxLength="50"
                                name="firstName" TabIndex="1" value="" Style="display: block;"></asp:TextBox>
                            <asp:RequiredFieldValidator EnableClientScript="true" ID="reqFirstName" runat="server"
                                ValidationGroup="modal" ControlToValidate="txtFirstName" ErrorMessage="Name Required"
                                Display="Dynamic" Style="color: Red;" />
                            <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="lblDuplicateEmailId" runat="server" Text="This Email Id is already present with us"
                                Visible="false" ForeColor="Red"></asp:Label>
                            <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" placeholder="Choose a passowrd"
                                class="txtFirstName" name="passwd" TabIndex="4" size="36" MaxLength="32" Style="margin-top: 15px;" /><br />
                            <asp:RequiredFieldValidator EnableClientScript="true" ID="reqPassword" runat="server"
                                ValidationGroup="modal" ControlToValidate="txtPassword" ErrorMessage="Password Required"
                                Display="Dynamic" Style="color: Red;" />
                            <asp:TextBox ID="txtConfirmPassword" runat="server" TextMode="Password" placeholder="Confirm password"
                                class="txtFirstName" name="passwd" TabIndex="5" size="36" MaxLength="32" Style="margin-top: 15px;" /><br />
                            <asp:CompareValidator runat="server" ID="cmpPassword" ControlToValidate="txtPassword"
                                ValidationGroup="modal" ControlToCompare="txtConfirmPassword" Text="Password mismatch"
                                Style="color: Red;" />
                            <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>


     

    Monday, September 26, 2016 3:15 AM

All replies

  • User-1142886626 posted

    Hi anuragrawat123,

    I have a gridview with colun "View" ID= "lnkViewContact". On click of this link signup modalpopupextender will be displayed. This popup is same for all the rows. But when I am running it the error I am getting is "Could not found control lnkViewContact". How can I resolve this.

    According to your description, I suggest you could add an OnClick event to the LinkButton and show modal on LinkButton1_Click event.

    Note: Since TargetControlID needed value, so must set a hidden button as Target Control of ModalPopupExtender or it will run an error.

    Code below is for your reference:

    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
         <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            Description
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            Description
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbldes" runat="server" Text='<%#Eval("Des") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:Button ID="Button1" runat="server" Text="Button" style = "display:none"/>
            <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
                cancelcontrolid="btnCancel" okcontrolid="btnOkay" 
    	         TargetControlID="Button1" popupcontrolid="Panel1" 
                popupdraghandlecontrolid="PopupHeader" drag="true" 
                backgroundcssclass="ModalPopupBG">
            </cc1:ModalPopupExtender>
            <asp:panel id="Panel1" style="display: none" runat="server">
    	   <div class="HellowWorldPopup">
                    <div class="PopupHeader" id="PopupHeader">Header</div>
                    <div class="PopupBody">
                        <p>This is a simple modal dialog</p>
                    </div>
                    <div class="Controls">
                    <input id="btnOkay" type="button" value="Done" />
                    <input id="btnCancel" type="button" value="Cancel" />
    		</div>
            </div>
           </asp:panel>
        </form>
    </body>
    
    protected void LinkButton1_Click(object sender, EventArgs e)
            {
                ModalPopupExtender1.Show();
            }
    

    Screen shoot:

    Best regards,

    Ailleen



    Tuesday, September 27, 2016 8:44 AM