Showing posts with label beta. Show all posts
Showing posts with label beta. Show all posts

Wednesday, March 28, 2012

Modal Popup Error Message

There have been several posts regarding the modal popup control and beta 2 but I haven't seen one regarding my issue yet. Here is a code sample of the page:

<atlas:ModalPopupExtender ID="mpeCutAreas"
BackgroundCssClass="modalPopupBg"
TargetControlID="btnHidden"
PopupControlID="pnlCutAreas"
CancelControlID="btnCloseCutAreas"
DropShadow="true"
runat="server" />
<asp:Button ID="btnHidden" UseSubmitBehavior="false" Style="visibility: hidden;" runat="server" />
<asp:Panel ID="pnlCutAreas" Style="display: none;" CssClass="modalDialog" runat="server">
<input type="hidden" id="hidGeographyId" runat="server" />
<div>
<h2>Cut Areas</h2>
<asp:DataGrid CssClass="grid" ID="dgCutAreas"
AutoGenerateColumns="false"
ShowFooter="true"
OnItemCommand="dgCutAreas_ItemCommand"
OnItemDataBound="dgCutAreas_ItemDataBound"
ShowHeader="true"
GridLines="None"
DataKeyField="CA_ID"
runat="server">
<HeaderStyle CssClass="gridHeader" />
<ItemStyle CssClass="gridItem" />
<AlternatingItemStyle CssClass="gridAltItem" />
<FooterStyle CssClass="gridFooter" />
<Columns>
<asp:TemplateColumn HeaderText="Active">
<ItemTemplate>
<asp:HiddenField ID="hidCutAreaId" Value='<%# DataBinder.Eval(Container.DataItem, CutArea.ColumnNames.CA_ID) %>' runat="server" />
<input type="checkbox" id="chkIsActive" runat="server" />
</ItemTemplate>
<FooterTemplate>
<input type="checkbox" disabled="disabled" id="chkIsActive" runat="server" />
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<input type="text" id="txtName" size="22" value='<%# DataBinder.Eval(Container.DataItem, CutArea.ColumnNames.CA_Name) %>' runat="server" />
</ItemTemplate>
<FooterTemplate>
<input type="text" id="txtName" size="22" runat="server" />
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<FooterTemplate>
<asp:Button ID="btnAddCutAreaRow" CommandName="Insert" Text="Add" runat="server" />
</FooterTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<br />
<asp:Button ID="btnSaveAllCutAreas" OnClick="btnSaveAllCutAreas_Click" Text="Save" runat="server" />
<asp:Button ID="btnCloseCutAreas" Text="Close" runat="server" />
</div>
</asp:Panel>


The error I am recieveing is this:

The control 'btnHidden' already has a data item registered.
Parameter name: control


One strange thing I did notice, is that if I set AutoEventWireup = false the problem goes away, but of course I'd rather not have to manually wire up the page when using C#. Not sure if that is a clue or not.

This code did work fine under beta 1.

Any help would be great.

Thanks,
Frank

Pasting your sample into a page and getting it running seems to work for me with either setting of AutoEventWireup. Perhaps acomplete, simple, self-contained sample page that demonstrates the problem would help? Thank you!

Having the same problem.. anyone have any idea what would cause it..

In my situation I am using an updatepanel in a masterpage, and inside that I have a control createaccount, that has a panel in it which I have assigned to the modal popup extender, which sits in the masterpage it works fine, but after I trigger a postback manually, and re-show the panel, I get that error! Its strange cause if I don't call the mpecreateaccount.show() method it works fine, I only seem to get it after i call mpecreateaccount.show()..

Any ideas would be greatly appreciated!

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.