I am just a beginner at javascript. Why is this not working? This is on a contenpage. I am trying to popup a popupextender cpontrol that is located in a user control, that is in a formview control.
this has worked well for me in scenarios where the MPE is not encapsulated in a user control, but this still should work...either way, in your browser, the MPE has to render as HTML, so have a look at the source and see what your control's behaviorID is.
I am not an expert in neither javascript nor ajax but I think from what I understand that an extender like the ModalPopupExtender does not really render any HTML. I think what it does is it renders javascript code to give a certain behavior to an existing
control. so what you say here: "either way, in your browser, the MPE has to render as HTML, so have a look at the source and see what your control's behaviorID is." is not correct (I think)
Also there has to be more depth to the ClientID issue. It cannot be as simple as seting up a behavior ID and just calling it directly (or maybe it can) because I think for example what if the MPE was inside a itemtemplate of a listview control. In a scenario
like this there would be more than one instance of that MPE ans so how then would my javascript know which MPE ewxactly I am refering to... there has to be a way to differenciate between them all
bcweed966
Member
261 Points
893 Posts
Help with javascript $find() and modalpopup
Oct 21, 2008 12:42 AM|LINK
I am just a beginner at javascript. Why is this not working? This is on a contenpage. I am trying to popup a popupextender cpontrol that is located in a user control, that is in a formview control.
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server"> <script type="text/javascript">function pageLoad() {
var ClientidV = "<%=CType(CType(FormView1.FindControl("editalbum1"), UserControl).FindControl("mpeup1"), AjaxControlToolkit.ModalPopupExtender).ClientID %>";$find(ClientidV).show();
}
</script>
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"> </asp:ScriptManagerProxy> <asp:UpdatePanel ID="UpdatePanel6" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false"> <ContentTemplate> <asp:HiddenField ID="AlbumIDTag" runat="server" />
<asp:HiddenField ID="EditAlbumTogleTag" Value="0" runat="server" /> <asp:FormView SkinID="AlbumCover" DataSourceID="AlbumCoverViewData" ID="FormView1" runat="server"> <ItemTemplate><
uc11:EditAlbum ID="EditAlbum1" runat="server" />shalan99
Member
195 Points
159 Posts
Re: Help with javascript $find() and modalpopup
Oct 21, 2008 07:45 AM|LINK
Hi there,
I haven't tested this for a user control and this is just a theory...but should in all fairness still work.
Give your popupextender a unique BehaviorID property. In your "pageLoad()" javascript function simply do a "$find('myBehaviorID').show();"
so in your usercontrol you will have your PopupExt as follows:
<ajaxToolkit:ModalPopupExtender ID="mpePopup" runat="server" BehaviorID="myBehaviorID" .....></ajaxToolkit:ModalPopupExtender>
this has worked well for me in scenarios where the MPE is not encapsulated in a user control, but this still should work...either way, in your browser, the MPE has to render as HTML, so have a look at the source and see what your control's behaviorID is.
hope that helps!
bcweed966
Member
261 Points
893 Posts
Re: Help with javascript $find() and modalpopup
Oct 21, 2008 04:35 PM|LINK
thank you shalan99,
I am not an expert in neither javascript nor ajax but I think from what I understand that an extender like the ModalPopupExtender does not really render any HTML. I think what it does is it renders javascript code to give a certain behavior to an existing control. so what you say here: "either way, in your browser, the MPE has to render as HTML, so have a look at the source and see what your control's behaviorID is." is not correct (I think)
Also there has to be more depth to the ClientID issue. It cannot be as simple as seting up a behavior ID and just calling it directly (or maybe it can) because I think for example what if the MPE was inside a itemtemplate of a listview control. In a scenario like this there would be more than one instance of that MPE ans so how then would my javascript know which MPE ewxactly I am refering to... there has to be a way to differenciate between them all
please someone shed some light on this for me...
ASPNewbFTW
Member
2 Points
1 Post
Re: Help with javascript $find() and modalpopup
Sep 23, 2009 06:08 PM|LINK
Thanks shalan, been trying this for a while and that took care of it!