Gridview无法找到modalpopupextender控件
本文关键字:modalpopupextender 控件 Gridview | 更新日期: 2023-09-27 18:08:41
我有一个列"View" ID= "lnkViewContact"的gridview。点击此链接,将显示注册模式popupextender。这个弹出窗口对所有行都是类似的。但是当我运行它时,我得到的错误是"找不到控件lnkViewContact"。如何解决。另一种选择是通过使用Onclick事件上的链接单击,但我不想做一个回发打开Popupextender。下面是我的代码:
<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>
当你提到'一种选择是使用Onclick事件上的链接点击,但我不想做一个回发打开Popupextender '时,这是有点混乱。如果你想要一个OnClick事件,你将不得不进行回发。以下是一个建议。
…这部分是你的代码....
<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: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>
在OnClick事件代码后面,这样做来显示弹出
mp1.Show()
Gridview中的Linkbutton不能设置为Modalpopupextender的TargetcontrolID,因为在运行时Linkbutton的ID会动态变化。周围的工作是使用LinkButton的Onclick事件,就像在我的情况下,如果有任何验证在modalpopupextender然后验证服务器端的控件。