[RESOLVED]Update Panel / Script Manager getting overwhelmed.

The short story, is when I have a bunch of databound controls(15+) all inside of an update panel it starts flaking out and not detecting changes. I have also had strange issues with radio buttons coming unselected after postback.

Here is the stackoverflow post about that.

http://stackoverflow.com/questions/18195063/how-to-get-radio-buttons-list-items-to-stay-selected-during-postback

For example. I had a lisbox whose selected indices were to populate a dropdownlist. On a minimal example, this worked fine. On  my  webforms page with 600 line of asp.net code and 2k of codebehind it did not. The minimal example was a direct copy and paste.

Worse yet still I had found a way to completely sever the connection between the webpage and the codebehind. (all events stopped firing in debug). Here is a video of what I am talking about.

https://docs.google.com/file/d/0B12ZVcp_VQ_xR3c0cU1LaXd5Vkk/edit?usp=sharing

Here is the StackOverflowPost that is related to it.

http://stackoverflow.com/questions/18278169/how-to-dynamically-copy-selected-listitems-from-a-listbox-to-a-dropdownlist-and

I  also had a similar experience in the past. I had posted my code for microsoft but they asked instead for a minimal example. Overwhelming update panels and the scriptmanager is impossible in minimal example according to all of my tests. To replicate this
you need 15+ databound controls with several of them with SelectedIndexChanged events that populate or change the visibility of other controls such as dynamially removing rows from a databound gridviews.  Or copying only the selected indicies from one listbox
to a dropdownlist.

This example works ( the minimal example 2 databound controls, 2 update panels 3 methods)

aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="AdminSite.Catalogdata.test" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:ScriptManager ID="ScriptManagerProxy1" runat="server" >
<Scripts>
<asp:ScriptReference Path="~/Scripts/MassUpdate.js" />
</Scripts>
</asp:ScriptManager>
<div>
<h3 style="color:Red; padding-left:5px;">
WARNING - This page can push large amounts of data into the database. Use care when using it!

</h3>
</div>
<asp:UpdatePanel ID="OverallUpdater" UpdateMode="Conditional" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<span id="Span1" runat="server" style="padding:8px; position:relative;">

<asp:Listbox AutoPostback="True" ID="GroupList" runat="server" Width="166px"
SelectionMode="Multiple" OnSelectedIndexChanged="GroupList_SelectedIndexChanged"
DataSourceID="GroupSource" DataTextField="GroupName" DataValueField="GroupID">
</asp:Listbox>
<asp:SqlDataSource ID="GroupSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ACESConnectionString %>"
SelectCommand="SELECT [GroupName], [GroupID] FROM [PrimaryGroup] ORDER BY [GroupName]"></asp:SqlDataSource>
</span>

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>

<asp:DropDownList runat="server" Width="150px" ID="grouplist2" DataTextField="Group" DataValueField="GroupID">

</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>

</div>
</form>
</body>
</html>

C# codebehind

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AdminSite.Catalogdata
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void GroupList_SelectedIndexChanged(object sender, EventArgs e)
        { updategroupEntry(); }

        protected void updategroupEntry()
        {
            string query = "";
            query += "SELECT    [GroupName] as [Group] ,  [GroupID] FROM [ACES].[dbo].[PrimaryGroup] Where ([GroupName] ='')";
            string[] y = query.Split(')');
            query = y[0];

            foreach (ListItem li in GroupList.Items)
            {
                if (li.Selected)
                {
                    query += " OR  [GroupName] = '" + li.Text + "' ";

                }

            }
            query += " )";
            DataTable dt = getDataTable(query);
            grouplist2.DataSource = dt;
            grouplist2.DataBind();

        }
        private DataTable getDataTable(string query)
        {

            SqlConnection con = new SqlConnection();
            con.ConnectionString = ConfigurationManager.ConnectionStrings["ACESConnectionString"].ConnectionString;
            con.Open();
            SqlCommand Subcmd = new SqlCommand(query);
            Subcmd.Connection = con;
            SqlDataAdapter da = new SqlDataAdapter(Subcmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            con.Close();
            con.Dispose();
            return dt;

        }
    }
}

This code was copied from the small file but originated from a larger file. It works
only in the smaller example but not the larger one, despite being self-contained.

Dear microsoft, I am loosing my patience with this issue. I have provided enough documentation for you to be able to replicate it. (See earlier comment).

That all being said. If you happen to see some solution to one of my stackoverflow posts, don’t hesistate to post it.

In the mean time, If you guys have a whole and complete post/tutorial  on How to use jQuery ajax with webservices so I can try to find a workaround that would be great.

hi zadkielmodeler ,

From what I understand  that you had strange issues with radio buttons coming unselected after postback with Update Panel and Script Manager and all inside of an update panel it starts flaking out and not detecting changes.

1. there is  a whole and complete tutorial  on How to use jQuery ajax with webservices:

http://www.asp.net/ajax/documentation/live/tutorials/UpdatePanelWithWebService.aspx

2. radio buttons coming unselected after postback:

http://stackoverflow.com/questions/843479/radiobuttonlist-is-unchecked-after-postback

http://forums.asp.net/t/1606830.aspx

i hope it helps you.

That is quite helpful thank you.

Well the radio button list coming unselected was not helpful because, no where in my code am I doing anything to unselect them. No jquery, no C# nothing.

But, thank you for the tutorial on webservices.

Just an odd item, but your example has an update panel within an update panel, your final page doesn’t have nested updatepanels does it?

It does have them.

When you say final page. I assume you are talking about something that I have never directly posted about. But I do have a big webpage in which I have some nested update panels. My example code is literally copied and pasted from my ‘final page’.

If you want I can give you the source code. But all the string building and database connection stuff would have to be replaced with your own, because I cannot give a copy of the database.

hi firend,

 i dont see your Update Panel  in  final page. I assume that your  issue is unselect them of dropdownlist  with  No jquery, no C# nothing .

i sugesst you to add empty ListItem and Selected.

using the HTML source:

<asp:DropDownList ID="DDL" runat="server" >
<asp:ListItem Selected="True"></asp:ListItem>
</asp:DropDownList>

if it not works, please post  your  the source code and  give me email.

Leave a Reply