Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Bit of a long one...changes to TextBox in Update Panel vanishing on Postback

$
0
0

Been having way too many strange issues with using the AJAX model popup, so I am trying to find a JQuery solution. Thought I had it down, but apparently I am missing something with the working between the CLient and Server side.

So to start, I use a JQuery click event to show a DIV. The DIV has an UpdatePanel in it as when I show it I need to grab some stuff from my database based on what is selected, so I use the following JQuery:

$('a[name=modal]').click(function (e) {
                //Cancel the link behavior
                e.preventDefault();
                //Get the A tag
                var id = $(this).attr('href');

                //Get the screen height and width
                var maskHeight = $(document).height();
                var maskWidth = $(window).width();

                //Set height and width to mask to fill up the whole screen
                $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

                //transition effect
                $('#mask').fadeIn(200);
                $('#mask').fadeTo("slow", 0.8);

                //Get the window height and width
                var winH = $(window).height();
                var winW = $(window).width();

                //Set the popup window to center
                $(id).css('top', winH / 2 - $(id).height() / 2);
                $(id).css('left', winW / 2 - $(id).width() / 2);

                //transition effect
                $(id).fadeIn(200);

                __doPostBack('ctl00_ContentPlaceHolder1_tcAuditMain_tabAuditScheduleReport_udpDialog', '');

            });

This works, the DIV appears, the UpdatePanel fires a partial postback and it's Load event grabs the data I need. Well, once you make changes, you click the OK button, which is a PostBAckTragger for the UpdatePanel.

<div id="boxes"><!-- #customize your modal window here --><div id="dialog" class="window">                        <asp:Panel ID="pnlAuditNote" CssClass="pnlBackGround" runat="server" Width="450px"><asp:UpdateProgress ID="UpdateProgress4" runat="server"><ProgressTemplate><div style="text-align: center; color: Red; font-size: 12px; font-weight: bold; position: relative;"><img src="images/ewestcor_loader.gif" alt="Loading" /></div></ProgressTemplate></asp:UpdateProgress><asp:UpdatePanel ID="udpDialog" runat="server"><ContentTemplate><div style="padding: 5px;"><asp:Panel ID="pnlDragNote" runat="server"><asp:Label ID="Label6" runat="server" Text="Audit Note" Font-Bold="True" Font-Size="Large"></asp:Label></asp:Panel><br /><asp:TextBox ID="txtAuditNote" runat="server" TextMode="MultiLine" Height="100px" Width="90%"></asp:TextBox></div><table><tr><td colspan="2" align="left"><asp:Button ID="btnOKNote" runat="server" Text="OK" UseSubmitBehavior="False" /><asp:Button ID="btnHackOKNote" runat="server" Text="OK" Style="display: none" /><asp:Button ID="btnCancelNote" runat="server" CssClass="close" Text="Cancel" UseSubmitBehavior="False" /><%--<input class="close" type="button" value="Cancel" />--%></td></tr></table><a href="#" class="close">Close it</a></div>                   </ContentTemplate><Triggers><asp:PostBackTrigger ControlID="btnOKNote" /><asp:PostBackTrigger ControlID="btnCancelNote" /></Triggers></asp:UpdatePanel></asp:Panel><!-- Do not remove div#mask, because you'll need it to fill the whole screen --><%--<div id="mask"></div>--%></div></div>

This triggers the post back, and the OK button's Click event fires. However the value of the Text field that is changed has reverted back to what it was when the first partial post back loaded it. That is, if the UpdatePanel_Load event set it to: "My Note", and then I change it in the browser to "My note has changed", then the OK button's click event still reads it as "My Note". I looked for obvious things, like it being reset in the Page_Load event but no dice.



Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>