Sunday, March 11, 2012

Problem showing Modal Popup through client side script

Well,

Ist is known that the $find function works with behavior IDs only and not with control IDs (despite of the writings in the documentation). You'll need to specify BehaviorID for your extender:

<ajaxToolkit:ModalPopupExtender ID="MPNoShow" BehaviorID="BENoShow" runat="server" CancelControlID="BNoShowCancel"
DropShadow="true" PopupControlID="PNoShow" PopupDragHandleControlID="PNoShow"
TargetControlID="PNoShow">
</ajaxToolkit:ModalPopupExtender>

Then in your script:

<script type="text/javascript">
function showpopup()
{
event.bubble = false;
$find('BENoShow').show();
alert('Complete');
}
</script>

And it will function.

Kind regards,

sbogus.


That is not 100% correct. $find works with a ClientID or a BehaviorID. If you are using a masterpage then the ClientID of your modalpopup will be slightly different to the ID of your modalpopup. So, the safest way to reference the modalpopup is to assign a BehaviorID and use that in the $find although you could use $find('<%=MPNoShow.ClientID%>') as well.


Thanks to both of you for the quick reply.

Both ways solved my problem.

Oliver

No comments:

Post a Comment