Solved

ASP.net AJAX Postback Problem

Posted on 2007-04-06
6
818 Views
Last Modified: 2013-11-26
I am using Visual Studio 2005 with the AJAX extension.  I put a timer and a label control in an update panel.... The timer updates the labeltext to the current time once a second... I have a listbox outside the update panel and it is posting back once a second... (with the timer)... I have other controls on the same page thhat are NOT posting back...

the question is WHY is the control posting back... and how to STOP IT...

Please dont respond with javvascript options to put a timer on my page... the use of these controls is only a test of the AJAX functionality.

Thank you for your help...
0
Comment
Question by:NTGuru705
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 22

Accepted Solution

by:
_TAD_ earned 500 total points
ID: 18865382
you put the timer in the updte panel as well?   That doesn't sound right.

Using AJAX
1) Add ScriptManager control to web page
2) Add UpdatePanel to Web Page
3) Add controls to UpdatePanel that you want to change for a given event (button click, timer tick, whatever).  The event firing control is usually not included - especially if they are timers.
4) Add control/timer which fires event to web page not to update panel (they can be part of the panel if they are manual event - like a button.  Automated event firing controls should not be included in the update panel.
5) Configure event firing control (set timer ticks, etc)
6) Add trigger/event from event firing control to the UpdatePanel Triggers collection
0
 
LVL 1

Author Comment

by:NTGuru705
ID: 18866276
Yes but take a look at this code for me.. the issue is that when the code below runs and the timer fires I always see the load event for lstqueues fire... this doesnt make any sense since the timer is inside a totally different updatepanel.

Thanks

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="doc.aspx.vb" Inherits="doc" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Untitled Page</title>

</head>

<body>

    <form id="form1" runat="server">

        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">

        </asp:ScriptManager>

        <asp:UpdatePanel runat="server" ID="udpTime" UpdateMode="conditional">

            <ContentTemplate>

                <asp:Timer ID="Timer1" runat="server" />

                <asp:Label runat="server" ID="lblTime" Text=" " Height="17px" />

            </ContentTemplate>

        </asp:UpdatePanel>

        <asp:UpdatePanel runat="server" ID="udpDocQueueList" UpdateMode="Conditional">

            <ContentTemplate>

                    Available Doc Queues:

                    <br />

                    <asp:DropDownList runat="server" ID="ddlQueues" /><br />

                    <br />

                   <asp:ListBox runat="server" ID="lstQueue" Height="100px" Width="300px"></asp:ListBox>

                    <asp:Button ID="btnGetDocs" runat="server" text="GO" Width="30px" />

            </ContentTemplate>

        </asp:UpdatePanel>

    </form>

</body>

</html>

 

 

Partial Class doc

    Inherits System.Web.UI.Page

 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then

            'set up timer interval

            Timer1.Interval = 1000

            Timer1.Enabled = True

 

            'populate the drop down list

            ddlQueues.Items.Add("Default")

            ddlQueues.Items.Add("Test")

 

            'populate the list box

            lstQueue.Items.Add("Test1")

            lstQueue.Items.Add("Test2")

            lstQueue.Items.Add("Test3")

        End If

    End Sub

 

    Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        lblTime.Text = Now.ToString

    End Sub

 

    Protected Sub lstQueue_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstQueue.Load

        'add a break point here to watch this event fire once a second,

        'even though the list box is not in the update panel with the timer.

    End Sub

End Class

 
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 18868298
Hmm.... well, according to your code, the list box is in an UpdatePanel although it is in a different panel from the label and timer.

Things to try/verify:

1) Look at your second update panel (the one the list box resides in) and verify that the UpdatePanel.Triggers collection is empty (or at least is not tied to the timer event or the other UpdatePanel).

2) take the timer out of the update panel and put it on the web page.  While I don't believe that this is causing a problem it is extra traffic and impacts performance (all 8 KB of it).  Ok, so maybe not a *huge* impact, but why add to the footprint?  87 KB * 3,000 concurrent users can start to add up.


As for testing, that wil have to wait a couple of days until after the Easter holiday.
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 14

Expert Comment

by:existenz2
ID: 18870586
<asp:UpdatePanel runat="server" ID="udpDocQueueList" UpdateMode="Conditional">

change that to:

<asp:UpdatePanel runat="server" ID="udpDocQueueList" UpdateMode="Conditional" ChildrenAsTriggers="False">

That might work (DropDownLists and UpdatePanel are evil though, I got some serious (performance) issues with those)
0
 
LVL 1

Author Comment

by:NTGuru705
ID: 18876944
Existenz we put a break on the load event for the listbox and we are still seeing that event fire...

I suppose I dont understand why the event would fire...

TAD - The triggers collection is empty....
0
 
LVL 1

Author Comment

by:NTGuru705
ID: 18966073
botttom line is the AJAX with MS is quite "buggy"... hopefully the next version will refine the deployment and correct some of the complication using AJAX in the visual studio enviroment.

I will give TAD the points for effort but we abandonded the AJAX for all but basic things in this project.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question