Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

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.

Control cpe_ClientState0 of type HiddenField must be placed inside a form tag with runat=s

What should i do ?

Hi,

is that control added dynamically? If so, drop a PlaceHolder control in the page and then add the control to that PlaceHolder.

Content of popup, this is a problem

It seems that content of modal popup is in same page. is there any way to load content of a poupup from a web form without iframe or dynamic user control.

Sorry for my bad inglish

If you don't want to use an iframe, you could try using ahttpWebRequest.


Hi Nima,

Based on my experience , I think the easiest way is putting an UpdatePanel inside the Popped up Panel. So when we want to show the ModalPopupExtender , we first force the UpdatePanel to be refresh and get data from the server then make the ModalPopupExtender be shown. Here is the sample.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title> <style> .modalBackground { background-color:Gray; filter:alpha(opacity=70); opacity:0.7; } .modalPopup { background-color:#FFD9D5; border-width:3px; border-style:solid; border-color:Gray; padding:3px; width:250px; } </style> </head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Button ID="Button2" runat="server" Text="Button" Enabled="false" style="display:none"/> <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Height="50px" Width="235px" style="display:none" DefaultButton="Button4"> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate><%=DateTime.Now.ToString()%> </ContentTemplate> </asp:UpdatePanel> <asp:Button ID="Button1" runat="server" Text="Cancel" /> <asp:Button ID="Button4" runat="server" Text="Button" /> </asp:Panel> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button2" PopupControlID="Panel1" CancelControlID="Button1" DropShadow="true" BackgroundCssClass="modalBackground"> </ajaxToolkit:ModalPopupExtender> <input id="Button3" type="button" value="Click Me" onclick="showModalPopup()"/> <script type="text/javascript" language="javascript"> function showModalPopup(){ __doPostBack('<%=UpdatePanel1.UniqueID%>',''); $find("<%= this.ModalPopupExtender1.ClientID%>").show(); } </script> </form></body></html>
Another way is using WebService. We can get different content by sending the different contextKey.
I hope this helps.
Best regards,
Jonathan

Hi

Content of popup is asp.net form. if I use httpWebRequest or webservice form not work


Thanks

Wednesday, March 21, 2012

Composite control does update second time

So I have a composite control that allows me to generate a form with our having to write out all the table stuff. It looks some thing like:

<cc2:FieldList ID="flUsers" runat="server" LabelCellCssClass="labelCell"> <Fields> <LDAPField FieldID="NetID" Label="Net ID:" Required="true" OnLDAPFieldClick="LoadLDAPFields" /> <TextField FieldID="FirstName" Label="First Name:" Required="true" /> <TextField FieldID="LastName" Label="Last Name:" Required="true" /> <TextField FieldID="Email" Label="Email:" Required="true" /> <TextField FieldID="Phone" Label="Phone #:" Required="true" /> <TextField FieldID="Room" Label="Room #:" Required="true" /> <DropDownField FieldID="Departments" Label="Dept:" DataSourceID="sqldsDepartments" DataTextField="DepartmentName" DataValueField="ID"> </DropDownField> <DropDownField FieldID="UserTypes" Label="User Type:" DataSourceID="sqldsUserTypes" DataTextField="UserType" DataValueField="ID"> </DropDownField> </Fields> <Buttons> <Button ID="btnAddUser" runat="server" Text="Add User" OnClick="btnAddUser_Click"> </Button> <Button ID="btnClearFields" runat="server" Text="Clear" CausesValidation="false" OnClick="btnClearFields_Click"> </Button> </Buttons></cc2:FieldList>
At this point in time, we have the ability to assign events to all the buttons, and onchange events to the drop down lists. Everything works fine when there is no update panel surrounding it. We, however, would like it to work with an update panel. The control renders fine on the initial page load. It also works fine on the first event we fire such as clicking a button or changing drop down index. We run into problems when we click buttons or change indexes after that. Nothing works after. Does anyone have any ideas?

in the updatepanel do you have "ChildrenAsTriggers="false"" and do you have "UpdateMode="Conditional""? If not try UM=f first, then UM=f & CAT=f and see if that solves your problem...

p.s. setting UM=c means you'll need to use triggers to update the updatepanel fromoutside the updatepanel. anything inside that calls a postback will automatically cause the updatepanel to do an async postback