Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Saturday, March 24, 2012

Modal Popups with Master pages?

Is there some trick when using a modal popup within a control of a masterpage? Where is one suppose to put the script manager, in the master page or in each individual page... I don't know what I'm doing wrong but it's not working right now. The panels that I want to be popups are just appearing on the page embedded like normal and when I click the button that would normally activate them the page just does a complete refresh and nothing else happens. Thanks in advance!

I'm pretty sure it's because of the evil "sys is undefined" error message. Well it's good to know that it's not something I'm doing =).


Wait a minute, why does AJAX work fine on other applications I have made in other instances of VS 2005, but with this particular web application it says "sys is undefined" ?


Found this post on google and it fixed it. Added the following line to web.config within the httphandlers tag:

<add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>

The original post:http://forums.asp.net/t/1055400.aspx Thanks Jasson King who posted that about 7 months ago! =)


What is going on... I added that line in web.config and it worked fine for about 2-3 hours and then for one reason or another I had to restart the application and now it's back to the same old business of "unknown element, could be a compilation error"...

What else is there to do?


Made another find.

<%@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>

I'm using master pages and I have this line of code in one of the pages that is displayed in the content holder, but I also found it in the master page file. I commented it out of the master page code and now it all works fine again...

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.