?
Solved

ASP.net AJAX Postback Problem

Posted on 2007-04-06
6
Medium Priority
?
835 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 2000 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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