Ajax events not working until page posts back

 I have a page that uses an update panel to refresh content.  The problem I am having is that buttons that are inside of the update panel never seem to return from the call they are making when the page loads the first time, but if I click a button outside of the update panel and post the whole page back, the buttons inside of the update panel work fine after that.  Has anyone ever heard of this happening and have any idea what I may be doing wrong?  The update panel is definately going through the events and updating the database etcetera but it just hangs when it finishes.

0
EnterTheUser
11/17/2008 2:15:38 PM
asp.net.ajax-ui 9760 articles. 0 followers. Follow

3 Replies
587 Views

Similar Articles

[PageSpeed] 19

Show us your code.  I had a lot of problems at first getting things to work properly


Mark this post as the "Answer" if it was the answer.
0
sswanner1
11/17/2008 4:33:22 PM

This is the page:

<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">

        </asp:ScriptManager>

        <table class="FixedWrapped" id="Table1" style="WIDTH: 800px" cellspacing="1" cellpadding="1" border="0">
            <tr>
                <td valign="top" align="left">
                    <uc1:MenuControl id="MenuControl1" runat="server"></uc1:MenuControl>
                    <asp:Button ID="Button1" runat="server" Text="Button" />
                </td>
            </tr>
        </table>
        <asp:UpdatePanel ID="udpDetails" runat="server"><ContentTemplate>
            <div id="navmenu">
                    <asp:Label runat="server" ID="lblOrderDetails" Height="18px" Font-Size="medium" Font-Names="arial" Font-Bold="True">Order Details</asp:Label>
               
             <%--<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                 <ContentTemplate>--%>
                    
                    <ul>               
                          <li><asp:Button ID="btnEditMode" runat="server" Width="65px" Height="23px" Font-Size="XX-Small" Font-Bold="True" Text="Edit" />
                           
                          </li>
                          <li><asp:Button ID="btnCancelEdit" runat="server" Width="65px" Height="23px" Font-Size="XX-Small" Font-Bold="True" Text="Cancel" /></li>
                          <li>
                            <asp:Button ID="btnSaveChanges" runat="server" Width="65px" Height="23px" Font-Size="XX-Small" Font-Bold="True" Text="Submit" OnClientClick="submitRequests(phDetail.ID);" />
                            <cc1:ConfirmButtonExtender ID="btnSaveChanges_ConfirmButtonExtender"
                                runat="server" ConfirmText="Are you sure you want to submit?" Enabled="True" TargetControlID="btnSaveChanges">
                            </cc1:ConfirmButtonExtender>
                          </li>

                          <li class="buttonSpace"><asp:Button ID="btn3235s" runat="server" Width="85px" Height="23px" Font-Size="XX-Small" Font-Bold="True" Text="White Pages" /></li>
                          <li><asp:Button ID="btnRequests" runat="server" Width="85px" Height="23px" Font-Size="XX-Small" Font-Bold="True" Text="Requests" /></li>
                          <li><asp:Button ID="btnTearPages" runat="server" Width="85px" Height="23px" Font-Size="XX-Small" Font-Bold="True" Text="Tear Pages" /></li>
                          <li><asp:Button ID="btnAttachments" runat="server" Width="85px" Height="23px" Font-Size="XX-Small" Font-Bold="True" Text="Attachments" /></li>
                          <li class="buttonSpace">
                              <asp:Button ID="btnNormalView" runat="server" Width="85px" Height="23px" Font-Size="XX-Small" Font-Bold="True" Text="Detail View" />
                          </li>
                       </ul>
                      
                    <div>
                        <asp:button runat="server" Width="125px" ID="btnApproveOrder" Height="23px" Font-Size="XX-Small" Font-Bold="True" Text="Approve All" Visible="False"></asp:button>           
                    </div>
<%--                  </ContentTemplate>
              </asp:UpdatePanel>  --%>               
              
            </div>               
            <div id="navmenu2">
            <table>
                <tr>
                    <td class="headerRowInfo" style="width:70px"><asp:Label runat="server" ID="Label1" Font-Underline="True" Font-Bold="True">Order#</asp:Label></td>
                    <td class="headerRowInfo" style="width:250px"><asp:Label runat="server" ID="label2" Font-Underline="True" Font-Bold="True">Client Name</asp:Label></td>
                    <td class="headerRowInfo" style="width:200px"><asp:Label runat="server" ID="Label3" Font-Underline="True" Font-Bold="True">Directory</asp:Label>
                    <asp:ImageButton runat="server" ImageUrl="images/mag2.gif" ToolTip="Directory Information" ID="ibtnDirInfo"></asp:ImageButton></td>
                    <td class="headerRowInfo" style="width:100px"><asp:Label runat="server" ID="Label4" Font-Underline="True" Font-Bold="True">Close</asp:Label></td>
                    <td class="headerRowInfo" style="width:58px"><asp:Label runat="server" ID="Label5" Font-Underline="True" Font-Bold="True">Issue</asp:Label></td>
                    <td class="headerRowInfo" style="width:100px; text-align:right;"><asp:Label runat="server" ID="Label6" Font-Underline="True" Font-Bold="True">Publisher</asp:Label></td>
                </tr>
                <tr>
                    <td class="headerRowInfo" style="width:70px; vertical-align:top;"><asp:Literal runat="server" ID="lblOrderNumber"></asp:Literal></td>
                    <td class="headerRowInfo" style="width:250px; vertical-align:top;"><asp:Literal runat="server" ID="lblClient"></asp:Literal></td>
                    <td class="headerRowInfo" style="width:200px; vertical-align:top;"><asp:Literal runat="server" ID="lblDirectory"></asp:Literal></td>                   
                    <td class="headerRowInfo" style="width:100px; vertical-align:top;"><asp:Literal runat="server" ID="lblClose"></asp:Literal></td>
                    <td class="headerRowInfo" style="width:58px; vertical-align:top;"><asp:Literal runat="server" ID="lblIssue"></asp:Literal></td>
                    <td class="headerRowInfo" style="width:100px; text-align:right; vertical-align:top;"><asp:Literal runat="server" ID="lblPublisher"></asp:Literal></td>                   
                </tr>                               
            </table>
           
            </div> 
 
            <div style="text-align:right; width:800px;">
                <asp:Button runat="server" Width="125px" ID="btnPrinterFriendly" Height="23px" Font-Size="XX-Small" Text="Printer Friendly" ></asp:Button>
            </div>
           
            <div>
                <asp:Label runat="server" Width="216px" ForeColor="Green" ID="lblApproveMsg" Visible="False"></asp:Label>
            </div> 

           
    <div id="up_container">
   


        <asp:PlaceHolder ID="phDetail" runat="server" EnableViewState="true"></asp:PlaceHolder>
        </div>
        </ContentTemplate>

    </asp:UpdatePanel>

    </form>
</body>

and here are the load, init, and a click event for one of the bottons:

     Private Sub order_details_new_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

        If Not IsPostBack Then
            Me.btnEditMode.Enabled = Not mblnEditMode
            Me.btnSaveChanges.Enabled = mblnEditMode
            Me.btnCancelEdit.Enabled = mblnEditMode
        End If

    End Sub

     Private Sub order_details_new_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
            'Ensures user has been authenticated
            If Not Context.User.Identity.IsAuthenticated Then
                LogOut(Context.Current)
                Response.Redirect("default.aspx", False)
            End If

            ScriptManager.GetCurrent(Page).AuthenticationService.Path = "/Authentication_JSON_AppService.axd"

            Page.ClientTarget = "ie5" 'disables browser sniffing (which doesn't work well) and allows controls to display correctly in Netscape v6/7

            Response.Expires = -1
            Response.AddHeader("Pragma", "No-Cache")
            Response.CacheControl = "no-cache"
            Response.Cache.SetCacheability(HttpCacheability.NoCache)

            'redirects page to timedout.aspx after x amount of time
            'session.timeout is set in iis - website properties/configuration and is in minutes
            Response.AppendHeader("Refresh", Convert.ToString(Session.Timeout * 60) & "; URL=home.aspx")

        End If

    End Sub

 

    Private Sub btnEditMode_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEditMode.Click

        mblnEditMode = Not mblnEditMode

        Me.btnEditMode.Enabled = Not mblnEditMode
        Me.btnSaveChanges.Enabled = mblnEditMode
        Me.btnCancelEdit.Enabled = mblnEditMode

        Me.thEnterNote.Visible = mblnEditMode
        For Each o As detailLine In Page.Form.FindControl("phDetail").Controls
            o.NoteCell.Visible = mblnEditMode
            o.NoteField.Visible = mblnEditMode
            o.NoteField.Enabled = mblnEditMode
            o.ApprovedCheckbox.Enabled = o.ApproveCheckEnabled
            o.ApprovedCheckbox.Visible = o.ApproveCheckEnabled

        Next

    End Sub

 

I didn't really want to post all the code since there are a lot of procedures and functions.  But these are the ones that could be a problem I suppose.  Basically clicking edit mode button makes some fields available to the user to enter some text and post back to database.   I'm also using an UpdatePanelAnimationExtender but that isn't the problem because I took that out and get the same results.  Stepping through the code, it does everything its supposed to but when it goes back to the page it's hung, as though it's still waiting for something to finish.  And as I said, if I click a button outside of the update panel and cause the whole page to be posted, the problem goes away.  Thanks for any help.  If more info is needed, let me know.

 

 

0
EnterTheUser
11/17/2008 5:03:17 PM

Sounds like a page lifecycle issue.

Keep in mind that your Button_Click event will fire after Page_Load and Page_Init. If you need Page_Load type code that runs after an OnClick event, use the PreRender event instead.


Encosia - ASP.NET, AJAX, and more.

Latest article: Using complex types to make calling services less… complex
0
gt1329a
11/18/2008 2:59:40 PM
Reply:

Similar Artilces:

Troubleshoot Web Service; Ajax AutoComplete events do not appear to not fire; Ajax web service appears to not work. .NET
Folks, I had the situation that Ajax AutoComplete events in the web service did not fire after I copied a project out of a folder, renamed it and moved it to a server. The fix was hard to find but easy to solve. I had some web service modules in an ASMX file that provided AutoComplete entries -- i.e., after the user keys in 2 or 3 characters, the list of possible entries with those leading characters is displayed for the user to select. To solve the problem, look at the web service's directive, not the code-behind or the ASMX designer.  Do a right-mouse-click...

Old AJAX in .NET 1.1 compatibility with .NET framework 2.0. Ajax does not work always ....................
Hello,I have converted the web site from .NET 1.1 to .NET 2.0. Some of the pages in the web site use AJAX which was developed in .NET 1.1Ajax does not work smoothly in .NET 2.0. Do I have to use ATLAS or is there any fix I can use to make the AJAX work ?Please let me know. Many thanks in advance. Nick..........

how does ajax work with is post back?
Hi All.How does ajax work with "Is Post back" in page_load? For example lets say there is a button which triggers off an update of a grid view in the data source. When the button is clicked, does this refresh the whole page ? because it causes the page_load method to go off. I'm a little confused.Thanks Watch this video might give clear idea. http://www.asp.net/learn/ajax-videos/video-177.aspxIf it solves your issue please mark this posting as "Answered".Thanks. Hi, When Button is as the trigger of UpdatePanel, it won't refresh the whole page. But it does th...

Why My Ajax Enabled Page Do Post Back?!
 Hi There.I Have My Ajax Anabled Project Which Works Fine In My PC.But When I Upload That It Doesn't Work.What's The Matter?Thanx In Advance Hi, Please check this link to configure an existing ASP.NET application. http://www.asp.net/learn/ajax-videos/video-81.aspx If you encountered the client 'sys' error meanwhile, please configure the web.config:     <httpHandlers>      <remove verb="*" path="*.asmx"/>      <add verb="*" path="*.asmx" validate=...

To AJAX, or not to AJAX?
Some body suggested to me to use AJAX. I figured it's not the brand name detergent nor the Dutch city. So here is what I have and please tell me if it ca be done with ajax, and perhaps point me to some examples, etc. The page contains several GridViews and FormViews that display data using several data calls. (Yeah, there is my first issue. Need to figure out how to cash all that.) This is an application that track work orders, so the top most FV has the user info and summary information of the work order. It is editable and so far it works well. There is also another set of infroamt...

ajax does not work with javascript post back
i have treeview that in inside ajax update panel, but my checkbox event is in the script side when ever i tick checkbox it refresh the whole page (ajax does not work) can some one help?   <%@ Page Language="C#" AutoEventWireup="true" CodeFile="treeview.aspx.cs" Inherits="treeview" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script language="javascript" type="text/javascript">function postBackByObject() ...

ajax or not to ajax.
Heres a strange one for you. I have a textbox, a button and a gridview on a page. I enter some search text which returns 500 odd records in under a second. When i wrap the gridview in an updatepanel, set its update mode to "conditional" and the trigger to the button the page can take 2-4 seconds to render. I think the problem is down to page redering some how as my progress indicator stops at around the same time as the normal postback would appear. I have also noticed this very behaviour and have come to the conclusion that in cases like this it is better to hand code a XMLHttp...

My AJAX is not AJAXing!
Hi, I was having trouble with a new AJAX enabled code so I tried to just to do a simple test page. I did the simple Label control with button example covered in this tutorial http://www.asp.net/learn/ajax/tutorial-01-cs.aspx I'm having the same problem. Functionalitw-wise it works but the page is refreshing and flickering. That means it's not the code but maybe my set up. I'm using VisualStudio 2005 and the application is currenty .NET 2.0. In VS.NET, I do see the AJAX controls though. What could this be?Thanks,Sam did you install the Ajax extensions? Now, it's AJAXing!...

System.Web.UI.Page and Ajax.net
 İ use .net 2005 and ajax.net.Normally i use System.Web.UI.Page,my webpage is working.But in here we use other page that extends System.Web.UI.Page.if i extend my class to our  webpage my ajax.net isn't  working. My error explanation is: sys.webfrom.pagerequestmanagerparserErrorException:the message received from the server could not beparsed.Common causes for this error are when the response is modifies by calls to Response.write(),response filters,httpmodules,or server trace is enabled. Details:Error parsing near'itle||Untitled PAge|<script language=J...

Fetch a page ajax with ajax
In the video number 30 presented by Joe Stagner in “How Do I?” videos, just in the beginning he says that we can fetch an existing aspx page into our page. I doing exactly the same right now, but I’m inserting a page with some controls that triggers events against the update panel that contains a repeater control, such as paging events, filtering and ordering data. I’ve tested the repeater’s control page and it’s working perfectly, though when I insert into another page and trigger an event I got an error, which is undefined. I still can see the page rendered in the first time, the problem o...

What are Ajax and Aspnet Ajax ,both work the same?
Hi, Hope some1 can help to explain. I am a bit of confused. For what I know, ajax, it is a native Javascript inside the javascript Library. and it is supported by most browser. To use ajax , I have to create it like this for Ms IE: var xmlHttp xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      or  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");  I believe I can use this script in Aspx page in Html section.     To use Aspnet Ajax:  How do I create the Ajax Object? And How do I use the ajax Properties and Methods? ...

Ajax controls/events in partial page updates w/o using Ajax UpdatePanel
 I company I work for has been using a old library ("slickback") which does XML-based form postbacks via javascript and replaces DIV tag sections (looks very much like how Ajax does panel updates).  It works somewhat okay for content updates w/o updating the page.  We'd like to someday move the whole system to AJAX but as of right now, there is no time to do so.We recently started using AJAX Controls such as the SliderExtender.  These work great......  until we do our slickback postback.  When the content is updated, the sliders disappear and all t...

Page with AJAX controls posts back twice to the server
I have a form containing three AJAX UpdatePanels, two of which contain a pair of listboxes and a pair of buttons, with the third one containing a pair of radio buttons in a radiobutton list and either three CascadingDropDown lists or two CascadingDropDown lists and a textbox depending on which radio button is selected.  The only other control on my form is a button to submit the information on the form to the server. One thing I've noticed is the information gets posted back to the server twice when the button is clicked.  This causes a duplicate record to be written to two ta...

Ajax UpdatePanel with Master Page (Full Post Back)
Need Help!!  I have implemented the </asp:UpdatePanel> into a stand-alone (no master page) web page and master/content page using C# and Ajax without any problem running through VS2005 and Windows XP in my personal computer. When I upload it to the web server, the stand-alone is running fine but the </asp:UpdatePanel> in the master/content is not working. The master/content page is always going to full post back when I click a button inside the UpdatePanel. I have find out that the problem may be the following. If I run the web page in my personal co...

Web resources about - Ajax events not working until page posts back - asp.net.ajax-ui

Working class - Wikipedia, the free encyclopedia
Working class (or lower class , labouring class, sometimes proletariat ) is a term used in the social sciences and in ordinary conversation to ...

This fitness apparel will tell you how hard your muscles are working
VIDEO: This fitness tracking gear will show you exactly how hard your muscles are working.

Xiaomi Mi 5 leaked: launching Feb 20, employees working overtime to meet demand
A third-party retailer in China has leaked the Xiaomi Mi 5 and its supposed launch date on February 20. According to the product page on Gear ...

2016 Google Tracker: Everything Google is working on for the new year
Android N, a big VR program, Google Glass, and lots more are in store for Alphabet.

The first working Hyperloop could arrive by the end of 2016
Filed under: Green , Videos , 2016 CES , Transportation Alternatives , Emerging Technologies , Future Engadget sat down with new Hyperloop Technologies ...

Hero of the working class
Hero of the working class by digby He'll be a rich, obnoxious boss to the whole world: The 45th president of the United States https://t.

This fitness apparel will tell you how hard your muscles are working
People are obsessed with measuring their daily health and fitness, and new technologies are constantly created to make it easier to track. Wearing ...

Republican debate: Fact checking Ted Cruz on working Americans
Is Cruz right when he says the U.S. has the lowest percentage of Americans working in almost 30 years?

Tesla Is Working On Autopilot Hardware Suite 2.0 — Confirmed By Elon Musk
... with Tesla’s CEO Elon Musk has confirmed what many have been speculating was the case — the pioneering electric car company is currently working ...

Titanfall dev working on new third person action property alongside Titanfall 2
Job listing reveals the genre of the studio's mysterious second project.

Resources last updated: 1/17/2016 4:56:08 PM