开发者

Display modal popup from code behind error

I have a datalist which has an ASP.NET image server control Id="imgCart". Now I want to display a modal pop up when user click on the image button. As every product must have different discription, I need to fill the gridview from the code behind. Below is the code:

asp:DataList Id=:ImageList" OnItemCommand="Item_Command" > ItemTemplate > asp:ImageButton Id=: "imgcart"

Code Behind:

protected void Item_Command(Object sender, DataListCommandEventArgs e)
    开发者_运维知识库{

        ImageButton img = (ImageButton)e.Item.FindControl("imgcart");
        string idProduct = img.ToolTip.Trim();
        ModalPopupExtender1.Show();
    }

Everything is working fine, expect the modal pop up is not being displayed.

Code for the Modal-pop up which [I have placed it outside the datalist]

 <cc1:ModalPopupExtender ID="ModalPopupExtender1"
     PopupControlID="PopupPanel" TargetControlID="imgcart" 
    runat="server">
   </cc1:ModalPopupExtender>



  <asp:panel id="PopupPanel" runat="server" BorderStyle="Groove" 
   BorderColor="black" BorderWidth="3px" BackColor="AliceBlue" 
   Height="200px" Width="200px" style="display: none"> 
       <asp:Label ID="lblPopup" runat="server" Text="popup!"></asp:Label><br />
        <br />
      <asp:DropDownList ID="ddlData" runat="server">
       </asp:DropDownList><br />
                    <br />              
       <asp:Button ID="btnPopupOK" runat="server" Text="Ok" />             
       <asp:Button ID="btnPopupCancel" runat="server" Text="Cancel" />         
     </asp:panel> 

Error Message

System.InvalidOperationException: The TargetControlID of 'ModalPopupExtender1' is not valid. A control with ID 'imgcart' could not be found.

Please help. I want to display modal popup from code behind!!

Edit1

When I placed the ajax modalpopup inside the datalist then it is displaying the modalpopup but it is not going to the code behind, I need a code behind event to get the product id.


Add a button with Display:none property.

<asp:ImageButton ID="imgcart" runat="server" style="display:none;" />

Hope it will help for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜