我有一个asp:网格视图和它里面我有一些TemplateFileds,其中一个用于显示一个HoverMenu面板给用户
更详细地说,网格视图显示个人信息,当用户将鼠标移到行上时,会出现一个面板,并显示完整的信息。
这是TemplateField
<asp:TemplateField meta:resourcekey="grdListTemplateFieldID">
<ItemTemplate>
<asp:HoverMenuExtender ID="HoverMenuExtender" runat="server"
PopupControlID="PopupMenu" PopupPosition="Center" OffsetY="30" OffsetX="10" PopDelay="50"
HoverCssClass="hoverMenu" >
</asp:HoverMenuExtender>
<asp:Panel ID="PopupMenu" CssClass="popupMenu" runat="server">
<div id="RequestHoverTitle">
<asp:Label ID="lblTitle" runat="server" meta:resourcekey="lblTitle" />
</div>
<div id="NameContainer">
<asp:Label ID="lblFullName" runat="server" SkinID="BoldLabel" meta:resourcekey="lblFullName" />
<asp:Label ID="lblReqName" runat="server" SkinID="ListLabel" Text='<%# Eval("Name") %>' />
<asp:Label ID="lblReqLastName" runat="server" SkinID="ListLabel" Text='<%# Eval("Family") %>' />
</div>。。一些其他的数据。
在后面的代码中,我有一个方法将ID (dataKeyname)提供给panel,用于它的内部工作
protected void grdList_RowDataBound(object sender, GridViewRowEventArgs e)
{
HoverMenuExtender hoverMenu = e.Row.FindControl("HoverMenuExtender") as HoverMenuExtender;
if (hoverMenu != null)
{
e.Row.Attributes["id"] = e.Row.ClientID;
hoverMenu.TargetControlID = e.Row.UniqueID;
}
}最后,对我来说一切都很好
我对这段代码有两个问题
首先:如果用户从具有所提供的注销链接的页面注销(在母版页中)将看到
The TargetControlID of 'HoverMenuExtender' is not valid. The value cannot be null or empty.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Source Error: 每当我想要回发页面时,这条消息就会出现(如果发生提交过程,或者文件上传,反之亦然
任何可能的帮助
发布于 2010-01-10 22:51:41
因为我在后面的代码中分配了HoverMenuExtender的TargetControlID,所以我没有在ASP标记中分配targetControlID,
因此,我将标记中HoverMenuExtender的targetControlID设置为GridView ID,问题就解决了。
对于即将到来的用户,我应该说你可以将HoverMenuExtender的targetControlID设置为你喜欢的任何ID,然后使你在代码背后设置它,它总是用一个有效的ID覆盖你的无效ID。
发布于 2010-01-05 01:30:06
尝试使用以下代码包装此代码:
if (e.Row.RowType == DataControlRowType.DataRow)
{
//assign target id
}https://stackoverflow.com/questions/1999726
复制相似问题