|
-
Jan 19th, 2012, 12:04 PM
#1
Thread Starter
New Member
[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.
-
Jan 19th, 2012, 05:46 PM
#2
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
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Jan 19th, 2012, 06:17 PM
#3
Thread Starter
New Member
Re: ModalPopupExtender Doesn't Recognize TargetControlID
 Originally Posted by sapator
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.
-
Jan 19th, 2012, 06:57 PM
#4
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.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Jan 19th, 2012, 07:09 PM
#5
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.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Jan 19th, 2012, 07:51 PM
#6
Thread Starter
New Member
Re: ModalPopupExtender Doesn't Recognize TargetControlID
 Originally Posted by sapator
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.
-
Jan 20th, 2012, 02:26 AM
#7
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
-
Jan 20th, 2012, 08:59 AM
#8
Thread Starter
New Member
Re: ModalPopupExtender Doesn't Recognize TargetControlID
Doesn't seem the link is working ..
Can you please check it ?
-
Jan 20th, 2012, 12:34 PM
#9
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
-
Jan 20th, 2012, 05:42 PM
#10
Thread Starter
New Member
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%" 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.
-
Jan 23rd, 2012, 02:06 AM
#11
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|