Results 1 to 11 of 11

Thread: [RESOLVED] ModalPopupExtender Doesn't Recognize TargetControlID

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    7

    Resolved [RESOLVED] ModalPopupExtender Doesn't Recognize TargetControlID

    I am getting an error when i call the button id which is inside GridView Item template.

    Error: "The TargetControlID of 'mpueResend' is not valid. A control with ID 'btnResend' could not be found."

    Code:

    Code:
    <asp:GridView ID="GridMultiD" runat="server" CellPadding="3" 
                            AlternatingRowStyle-BackColor="#EDF3F7" HeaderStyle-CssClass="gridbgheading" 
                            Width="100%" HeaderStyle-HorizontalAlign="Center" >
                            
                        
                        <Columns>
                            <asp:TemplateField HeaderText="Resend">
                                <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Button ID="btnResend" runat="server" Text="Resend" CssClass="text ButtonInline"  />
                                    </ItemTemplate>
                            </asp:TemplateField>
                            </Columns>
                            
                        </asp:GridView>
    Code:
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:ModalPopupExtender ID="mpueResend" runat="server" TargetControlID="btnResend" PopupControlID="pnlPopupResend" 
            BackgroundCssClass="modalBackGround" DropShadow="true" CancelControlID="btnCancelR" >
        </asp:ModalPopupExtender>
    Please let me know if there is any solution for this.

    Thank You.

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: ModalPopupExtender Doesn't Recognize TargetControlID

    Have you created any data?If not you try to bind to nothing.
    Also you can use gridview.findcontrol method in code behind if you still don't get something(haven't tried with popupextender to be honest.)
    Code:
       Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim d As Button
            d = GridMultiD.FindControl("btnResend")
            mpueResend.TargetControlID = d.ID
    
    
        End Sub
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    7

    Re: ModalPopupExtender Doesn't Recognize TargetControlID

    Quote Originally Posted by sapator View Post
    Have you created any data?If not you try to bind to nothing.
    Also you can use gridview.findcontrol method in code behind if you still don't get something(haven't tried with popupextender to be honest.)
    Code:
       Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim d As Button
            d = GridMultiD.FindControl("btnResend")
            mpueResend.TargetControlID = d.ID
    
    
        End Sub
    Thank You very much for the reply.

    Yes i got the data loaded.
    I tried to put the code which you suggest in page load event.

    Button d;
    d = (Button)GridMultiD.FindControl("btnResend");

    I am getting null value in d.
    I don't know if i am doing something wrong.

    What i want is that i need to add a button column inside the grid view and when that button is called need to open a popup with some values of that row.

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: ModalPopupExtender Doesn't Recognize TargetControlID

    yes now i see you are using asp:TemplateField .I'm not sure how to get the id there.I'll have a look and post if i find something.
    Also the try should be on page_load.My mistake.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: ModalPopupExtender Doesn't Recognize TargetControlID

    Code:
      Protected Sub GridMultiD_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridMultiD.DataBound
            For i As Integer = 0 To GridMultiD.Rows.Count - 1
                Dim d As Button = TryCast(GridMultiD.Rows(i).FindControl("btnResend"), Button)
                '   mpueResend.TargetControlID = d.ID
                Exit For
                
            Next
        End Sub
    although it won't help you.I have a blank of memory regarding the modalpopup and how you can use it.You can try to put a function to the OnClick event of the button and handle in code behind what you want to do.I can't help with modalpopup.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    7

    Re: ModalPopupExtender Doesn't Recognize TargetControlID

    Quote Originally Posted by sapator View Post
    Code:
      Protected Sub GridMultiD_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridMultiD.DataBound
            For i As Integer = 0 To GridMultiD.Rows.Count - 1
                Dim d As Button = TryCast(GridMultiD.Rows(i).FindControl("btnResend"), Button)
                '   mpueResend.TargetControlID = d.ID
                Exit For
                
            Next
        End Sub
    although it won't help you.I have a blank of memory regarding the modalpopup and how you can use it.You can try to put a function to the OnClick event of the button and handle in code behind what you want to do.I can't help with modalpopup.
    Okay. I will try to do this in a different way tomorrow if this doesn't work.
    Thank You for your effort.

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: ModalPopupExtender Doesn't Recognize TargetControlID

    Hello,

    I would suggest that you take a look here:

    http://mattberseth.com/blog/2007/07/...etes_with.html

    This seems to do everything that you need.

    Gary

  8. #8

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    7

    Re: ModalPopupExtender Doesn't Recognize TargetControlID

    Doesn't seem the link is working ..
    Can you please check it ?

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: ModalPopupExtender Doesn't Recognize TargetControlID

    Hello,

    I don't know what is happening with that link! It was working fine this morning.

    I would suggest that you try the link again later. If it is still the same, I will try to find another sample.

    Gary

  10. #10

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    7

    Re: ModalPopupExtender Doesn't Recognize TargetControlID

    I solved it.

    Added a dummy hidden field for ModalPopUp in aspx page and in code behind added ModalPopup.show().

    Code:
    <asp:HiddenField ID="hfHidden" runat="server />
    <asp:ModalPopupExtender ID="mpueResend" runat="server" TargetControlID="hfHidden" PopupControlID="pnlPopupResend" 
            BackgroundCssClass="modalBackGround" DropShadow="true" CancelControlID="btnCancelR" />
     
    <asp:GridView ID="GridMultiD" runat="server" CellPadding="3" AlternatingRowStyle-BackColor="#EDF3F7" HeaderStyle-CssClass="gridbgheading" Width="100&#37;" HeaderStyle-HorizontalAlign="Center" OnRowCommand="GridMultiD_RowCommand">  
        <Columns>
            <asp:TemplateField HeaderText="Resend">
                <ItemStyle HorizontalAlign="Center" />
                <ItemTemplate>
                     <asp:Button ID="btnResend" runat="server" Text="Resend" CssClass="text ButtonInline"  CommandName="ViewComments" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns> 
    </asp:GridView>

    Code:
    protected void GridMultiD_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName) // check the incoming command name
        {
            case "ViewComments":
                mpueResend.Show();
                break;
        }        
    }
    Thank You.

  11. #11
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] ModalPopupExtender Doesn't Recognize TargetControlID

    Glad to hear that you got it working!

    For me, that link now seems to be working again. Not sure what happened to it before.

    Gary

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width