Wednesday, March 28, 2012

Control dont work

I have a form with some fields inside a UpdatePanel. And I also have some panels that I'm using as modal panels (just like in the Atlas Control Toolkit examples).

Thats the modal code:

1 <atlasToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server">
2 <atlasToolkit:ModalPopupProperties TargetControlID="btnGravar" PopupControlID="pnlContPag" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btContpagCancela"/>
3 <atlasToolkit:ModalPopupProperties TargetControlID="btnDeletar" PopupControlID="pnlDelete" BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="btnDelSim" CancelControlID="btnDelNao"/>
4 </atlasToolkit:ModalPopupExtender>

My Problem is: When I try the modals when the fields are empty, the buttons works. But when I load data from the database into the fields, the modal works, but the buttons inside its panels dont!!!

I'm almost getting insane!!

Could anybody help me ?Here is it.
I have a panel called pnlDelete, which have 2 buttons. One of them kills the record, the other does nothing.
The problem is: The buttons do not work!

1<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>23<%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %>45<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">67<html xmlns="http://www.w3.org/1999/xhtml" >8<head runat="server">9 <title>Transufos::Servi?os de Oficina</title>10 <style>11 .modalBackground {12 background-color:Gray;13 filter:alpha(opacity=50);14 opacity:0.5;15 }16 .modalPopup {17 background-color:#ffffdd;18 border-width:3px;19 border-style:solid;20 border-color:Gray;21 padding:3px;22 }23 </style>24</head>25<body>26<form id="form1" runat="server">27 <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="XX-Large" ForeColor="Blue"28 Style="z-index: 108; left: 8px; top: 477px" Width="336px">Servi?os de Oficina</asp:Label><br />2930 <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />31323334 <atlas:UpdateProgress ID="UpdateProgress1" runat="server">35 <ProgressTemplate>36 <asp:Panel ID="Panel1" runat="server" Height="55px" Width="173px" BackColor="LightYellow" style="z-index: 999; left: 248px; position: absolute; top: 285px" BorderStyle="Solid" BorderWidth="2px" BorderColor="DarkRed">37 <asp:Image ID="Image2" runat="server" ImageUrl="~/animated_loading.gif" Style="z-index: 100;38 left: 23px; position: absolute; top: 22px" />39 <br />40 <strong>41              42 Carregando ... </strong>43 </asp:Panel>44 </ProgressTemplate>45 </atlas:UpdateProgress>464748 <atlas:UpdatePanel runat="server" ID="UpdatePanel1" Mode="Conditional">4950 <ContentTemplate>5152 <br />53 <br />5455 <asp:Label ID="lblMessage" runat="server" ForeColor="Red" Style="left: 24px; top: 970px"56 Width="708px" Height="37px"></asp:Label><br />57585960 <div style="display:none">61 <asp:Panel ID="pnlDelete" runat="server" BackColor="Salmon" BorderColor="Red" BorderStyle="Solid"62 BorderWidth="2px" Height="80px" Style="z-index: 112; left: 780px; position: absolute;63 top: 444px" Width="328px">64 <p align="center">65 <strong><font color="#000000">Este registro será EXCLUíDO. Tem certeza?</font></strong></p>66 <p align="center">67 <asp:Button ID="btnDelSim" runat="server" BackColor="White" CausesValidation="False"68 Font-Bold="True" ForeColor="Red" OnClick="btnDelSim_Click" Text="Sim" BorderStyle="Outset" />69               70 <asp:Button ID="btnDelNao" runat="server" BackColor="White" CausesValidation="False"71 Font-Bold="True" ForeColor="Red" OnClick="btnDelNao_Click" Text="N?o" /></p>72 </asp:Panel>73 </div>838485<!-- Modais //-->86 <atlasToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server">87 <atlasToolkit:ModalPopupProperties TargetControlID="btnGravar" PopupControlID="pnlContPag" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btContpagCancela"/>88 <atlasToolkit:ModalPopupProperties TargetControlID="btnDeletar" PopupControlID="pnlDelete" BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="btnDelSim" CancelControlID="btnDelNao" />89 </atlasToolkit:ModalPopupExtender>90<!-- Fim dos modais //-->9192939495 <asp:LinkButton ID="btnConsultar" runat="server" BackColor="Transparent" CausesValidation="False"96 Font-Bold="True" ForeColor="Black" OnClick="btnConsultar_Click" Style="left: 750px;97 position: absolute; top: 138px">Consultar</asp:LinkButton>98 <asp:LinkButton ID="btnGravar" runat="server" BackColor="Transparent" Font-Bold="True"99 ForeColor="Black" OnClick="btnGravar_Click" Style="left: 758px; position: absolute;100 top: 212px" TabIndex="34" Width="45px">Gravar</asp:LinkButton>101 <asp:LinkButton ID="btnDeletar" runat="server" BackColor="Transparent" CausesValidation="False"102 Font-Bold="True" ForeColor="Black" OnClick="btnDeletar_Click" Style="left: 758px;103 position: absolute; top: 286px">Deletar</asp:LinkButton>104  105 </ContentTemplate>106107108 </atlas:UpdatePanel>109110</form>111</body>112</html>

thankx
Please post a complete page that demonstrates the problem as simply as possible - we'll look into it.
I'm afraid your sample doesn't completely work for me. "pnlContPag" isn't present, so only one of the two ModalPopups can work. pnlDelete is wrapped in "<div style="display:none">" so it's never visible. Removing that display:none wrapper lets me see the delete panel and it seems that hitting either button in it works. Recall that the controls specified by ModalPopup's OkControlID/CancelControlID don't postback anymore, but instead run whatever code's been specified by OnOkScript/OkCancelScript. Might this be the issue?
Yeah, your are right, I have ommited some lines :)
It was really huge!!!!!!

But I'm having the same problem with the 'pnlContPag' and the 'pnlDelete'

hmmm...
It haven't worked.
The greatest problem is that I'm losing the reference to the code-behind events when using the modal panel. I need them to postback so I can delete (in the case of the pnlDelete...) the current record. I already have the functions on the .cs file with the code to delete the record.

HELP MEEEE!

Thanks again for the help!

Jeff
If you want a control in the ModalPopup to postback, don't hook it up as an Ok/Cancel button. It should postback normally and the act of posting back will dismiss the ModalPopup.

No comments:

Post a Comment