Wednesday, March 21, 2012

modalPopup _show() and $object(modalPopupExtndr).set_OnOkScript(script()) not working with

Over the last few days I have upgraded to the beta 1 and the latest ajaxControlToolkit...Now my modalPopup no longer works and I have been trying to figure a work around for the last day or so. I am using the code located athttp://www.geekzilla.co.uk/ViewDAAE6AAB-0369-45C2-BE78-B8E6F876B4F4.htm but now that <atlasToolkit:ModalPopupProperties no longer exists I am at ends trying to call the _show() method using the $object('modalPopupExtndr')._show() b/c i get a null error. I will post my exact code if needed, but it is a basic modalPopup...any ideas?


Thanks,
Greg

Quote from the migration guide... (http://blogs.msdn.com/sburke/archive/2006/10/20/atlas-control-toolkit-ajax-control-toolkit-migration-guide.aspx)

The$('...') alias fordocument.getElementById('...') has been changed to$get('...'). The$object('...') alias forSys.Application.findControl('...') has also been changed to$find('...'). See PopupControlBehavior.js:52.

It looks like you should try $find('modalPopupExtndr')._show()

Good Luck.


Referenced here too...

http://ajax.asp.net/ajaxtoolkit/Walkthrough/AtlasToAspNetAjax.aspx


Thanks for the reply but I think the problem is deeper than just changing it from object to find. I didn't change object to find b/c in the AspNet Ajax CTP to Beta Whitepaper doc I quote this from it: "In the CTP release, you could use the $object('GoShopping') construct to reference a component created as a result of xml-script. The Value-add release will continue to support this alias." Since I am using the Value-add I figured I would not need to change ojbect to find. However changing object to find did help solve one of my issues. The above quote can be found at this link:http://ajax.asp.net/files/AspNet_AJAX_CTP_to_Beta_Whitepaper.doc

Here is my code and it is erroring in the ShowMessageBox javaScript function on the $object('MsgBoxExtndrProps')._show(); call and I tried using find but that didnt work either. notice though that $object('MsgBoxExtndrProps')._hide(); works fine when I want to close the modalPopup...any ideas??:

<div id="MsgBoxDialog" class="MessageBox" style='display: none;'>
<div id="MsgBoxDialogHeader" class="PopupDialogHeader">
<img id="MsgBoxDialogCloser" class="PopupDialogCloser" alt="Close" onclick="$object('MsgBoxExtndrProps')._hide();"
src="http://pics.10026.com/?src=../Images/Closer.jpg" />
<span id="MsgBoxDialogTitle" class="PopupDialogTitle"></span>
</div>
<div id="MsgBoxDialogContent" class="MessageBoxContent">
<div id="MsgBoxQuestion" class="MessageBoxQuestion">
</div>
<div id="msgBoxButtons" class="MessageBoxButtons">
<input id="btnConfirm" type="button" value="Yes" />
<input id="btnNoConfirm" type="button" value="Cancel" />
</div>
</div>
</div>
<div style='display: none; visibility: hidden;'>
<asp:Button runat="server" ID="btnHidden" />
</div>
<ajaxToolkit:ModalPopupExtender
ID="MsgBoxExtndr" runat="server"
TargetControlID="btnHidden" PopupControlID="MsgBoxDialog"
BackgroundCssClass="modalBackground" DropShadow="true"
OkControlID="btnConfirm" OnOkScript="onOk()"
CancelControlID="btnNoConfirm" BehaviorID="MsgBoxExtndrProps">
</ajaxToolkit:ModalPopupExtender>

<script type="text/javascript">

var msgBoxQuestion; // content of the tskDlgDiv
var msgBoxTitle; // Title of the task dialog

InitMsgBox();

function InitMsgBox()
{
msgBoxQuestion = new Sys.Preview.UI.Label($get("MsgBoxQuestion"));
msgBoxQuestion.initialize();

msgBoxTitle = new Sys.Preview.UI.Label($get("MsgBoxDialogTitle"));
msgBoxTitle.initialize();
}

/*
When the user is about to make a significant change
this is used as a confirmation...if they answer yes, then
the command param is executed.
*/
function ShowMessageBox(title, question, command)
{
msgBoxTitle.set_text(title); // set the title of the messageBox
msgBoxQuestion.set_text(question); // Ask the question to the user
$find('MsgBoxExtndrProps').set_OnOkScript(command); // If they answer yes, execute this command
$object('MsgBoxExtndrProps')._show(); // try find or object and it does not work...however $object('MsgBoxExtndrProps')._hide(); works fine??
}
function onOk() { return true; }
</script>


Try this...

I changed this line...

$object('MsgBoxExtndrProps')._show();

to...

var popUp = $find('MsgBoxExtndrProps');
popUp.show();

and it popped the window.


Bravo Todd...It worked like a champ.

I just made it $find('MsgBoxExtndrProps').show(); and it worked without creating the extra var. It is strange how the _hide() works but the _show() doesn't...strange.

No comments:

Post a Comment