Secret_Squirrel Secret_Squirrel - 1 year ago 94
Javascript Question

Opening ModalPopupExtender Using JavaScript

I have a Popup in my aspx page that i want to open based on criteria that has to be met by javascript. The problem i am having is that i cannot seem to get the modalpopupextender to work no matter what i try.

I have tried using PageMethods, _doPostBack() and $Find(PopupClientId).Show();

None of the above seem to work and i cannot figure out why.

This is my JavaScript.

function RequotePopup(popup, status) {
if (status = true) {
var thePopup = document.getElementById(popup); = "visible";
} else {
alert("Please select a record for Re-Quote");
function checkGridView() {
var hdnCheckboxIDs = document.getElementById("ctl00_ContentPlaceHolder1_hdnCheckboxID");
var arrCheckboxIDs = hdnCheckboxIDs.value.split(",");
var checked = false;

for (var i = 0; i < arrCheckboxIDs.length; i++) {
if (arrCheckboxIDs[i] != "") {
var ckbItem = document.getElementById(arrCheckboxIDs[i]);
if (ckbItem != null) {
if (ckbItem.checked == true) {
checked = true;
if (checked == true) {
//var modal = $find('<%= ReQuoteBtn_ModalPopupExtender.ClientID %>');
} else {
alert("Please select a record for Re-Quote");

And This is my ASP.Net.

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />

<asp:Button ID="ReQuoteBtn" runat="server" Text="Re-Quote" OnClientClick="Javascript:checkGridView()"
CssClass="Sales" />
<asp:ModalPopupExtender ID="ReQuoteBtn_ModalPopupExtender" runat="server" DynamicServicePath=""
BackgroundCssClass="modalBackground" Enabled="True" BehaviorID="RequoteModal" PopupControlID="RequotePopup"
TargetControlID="ReQuoteBtn" OnCancelScript="cmdCancelrq">

Answer Source

I'm not sure if you have tried this, but it should work if you find the ModalPopupExtender by BehaviorID.

As your BehaviorID is RequoteModal, let try this sample:

To show the popup


To hide the popup



I just noticed that you set Enabled="False" for the ModalPopupExtender, this will not allow the modal to call show() method, you may got error message such "Unable to get property 'show' of undefined or null reference".

Please remove that setting and try again.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download