Wednesday, March 21, 2012

modalpopup & OnClick

I’ve been experimenting with AJAX for our Weather Web Site and I ran into a road block. I'm working with the modalpopup and hovermenu controls. I have an imagebutton that when clicked, opens the modalpopup. However, it also has an onClick call to a method in the C# code. Unfortunately, this method is never called because of the modalpopup.

Here’s the code where I create the button:

<asp:ImageButtonID="fireweatherten"runat="server"ImageUrl="images/bullseye.jpg"Height="18"Width="21"OnClick="fireweatherten_Click"/>

Here’s the code where I create the modalpopup:

<cc1:ModalPopupExtenderID="MPE1"runat="server">

<cc1:ModalPopupPropertiesTargetControlID="fireweatherten"PopupControlID="weather"CancelControlID="close"BackgroundCssClass="modalBackground"DropShadow="true"/>

</cc1:ModalPopupExtender>

Here’s the code where I create the hovermenu:

<cc1:HoverMenuExtenderID="HME1"runat="server">

<cc1:HoverMenuPropertiesTargetControlID="fireweatherten"HoverCssClass="popupHover"PopupControlID="popupMenuTen"PopupPosition="Bottom"PopDelay="25"/>

</cc1:HoverMenuExtender>

Basically, when the button is pushed, it should call the method (fireweatherten_Click) and the dataset from this call should be displayed on the modalpopup panel. If I delete the modalpopup code, the method is called and runs perfectly (it just doesn’t have anywhere to display the data). However, if I leave the modalpopup code, the method is never called and I get a blank panel displayed. Any help would be appreciated.

Thanks,

Luis

I think this post may help:http://forums.asp.net/ShowPost.aspx?PostID=1379165

David,

Thanks for the reply, but I'm actually trying to activate a click event for the same button that launches the modalpopup; not the click event for a button on the modalpopup. Let me explain...I am trying to allow users to fill in search information in various fields in a panel. When they click the search button, I need to take these field values and search my database. Then, rather than opening a new page to display the search results, I want to display them in the modalpopup.

Unfortunately, when I click the search button, the "onsearch_click" event in the code behind my page is never called. Instead, the modalpopup displays a blank results page. If I delete the modalpopup extender, my "onsearch_click" is called with no problem. So my current issue deals with calling a usual asp:button onclick event before the modalpopup is displayed. I've seen other questions about this so far in other groups, but not many answers yet. Any ideas?

Thanks,

Luis


Here is what I did. I added another button and htmlinputhidden.

<asp:Button ID="btnPopup1" runat="server" Text="Popup" OnClientClick="javascript:PopupOrder(); return true;" /><input type="hidden" runat="server" id="hidOrderFlag" value="0" /><input type="button" id="btnPopup2" runat="server" style="display:none;" /><cc1:ModalPopupExtenderID="ModalPopupExtender1" TargetControlID="btnPopupOrder" PopupControlID="pnlOrder" runat="server" BackgroundCssClass="modalBackground" ></cc1:ModalPopupExtender>
 <script type="text/javascript">function PopupOrder(){ setInterval('Popup()', 100);}function Popup(str){flag = document.getElementById('hidOrderFlag');if (flag){if (flag.value == '1'){document.getElementById('btnPopup2').click();flag.value = '0';}}}</script>

Code Behind:

Protected Sub btnPopup1_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnPopup1.Click'show grouped materials 'Do something to populate data to controls in modal popup hidOrderFlag.Value ="1"End Sub

Hope it helps.


Here is what I did. I added another button and htmlinputhidden.

<asp:Button ID="btnPopup1" runat="server" Text="Popup" OnClientClick="javascript:PopupOrder(); return true;" /><input type="hidden" runat="server" id="hidOrderFlag" value="0" /><input type="button" id="btnPopup2" runat="server" style="display:none;" /><cc1:ModalPopupExtenderID="ModalPopupExtender1" TargetControlID="btnPopup2" PopupControlID="pnl" runat="server" BackgroundCssClass="modalBackground" ></cc1:ModalPopupExtender>
 <script type="text/javascript">function PopupOrder(){ setInterval('Popup()', 100);}function Popup(str){flag = document.getElementById('hidOrderFlag');if (flag){if (flag.value == '1'){document.getElementById('btnPopup2').click();flag.value = '0';}}}</script>

Code Behind:

Protected Sub btnPopup1_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnPopup1.Click
 'Do something to populate data to controls in modal popup hidOrderFlag.Value ="1"End Sub

Hope it helps.


Thanks...I'll try this.

Luis

No comments:

Post a Comment