I have a asp:GridView and inside it I have some TemplateFileds, one of them used for show a HoverMenu Panel to User
in more details, gridview shows the personal information andwhen user mouseover the row a panel would appear andshows the complete information.
this is the TemplateField
<asp:TemplateField meta:resourcekey="grdListTemplateFieldID">
<ItemTemplate>
<asp:HoverMenuExtender ID="HoverMenuExtender" runat="server"
开发者_如何学JAVA 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>
. . some other data .
and in code behind I have a method that gives the ID (dataKeyname) to panel for its internal job it is
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;
}
}
and finally everything work fine for me
I have 2 problem with this code
first: if user Logout of the page with provided logout link (in master page) will see the
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:
and this message will appear whenever I want to Postback the page (if a submit proccess happen , or a fileupload or vice versa
any help appriciated
cause I have assigned TargetControlID of HoverMenuExtender in code behind in, so I didn't assign the targetControlID in ASP Markup,
so I set targetControlID of the HoverMenuExtender in Markup to GridView ID and the issue resolved,
for upcomingusers I should say that you can set targetControlID of the HoverMenuExtender to any ID you like, and then cause you set it in the codebehind, it everride your invalid ID with a valid ID.
Try wrapping this code with:
if (e.Row.RowType == DataControlRowType.DataRow)
{
//assign target id
}
精彩评论