• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1509
  • Last Modified:

scriptmanager in conjunction with toolkitscriptmanager using UpdatePanel

I need some help here.
I have a page which I am using the ToolkitScriptManager for the use of some AJAX Calendar Control Extenders, and that works fine.
Where I am running into a problem is using the UpdatePanel. I am not getting a partial or any postback on a listbox control. I have attached snippets of my code. How it is supposed to work is when a user clicks on an item in the Listbox it should update the lblLeads Label. Of course it should do this using Ajax, without doing a Postback noticeable to the user.

I have tried adding the regular ScriptManager and I get errors and when I have both of them loaded, ToolkitScriptManager and ScriptManager, I get an error saying that you can only have one Scriptmanager on the page.

Please help.

Thanks in advance.
<body>
<form id="form1" runat="server">
<div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>

little further down... 

[List box code]
<td class="style7">
&nbsp;<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple" Width="199px" DataSourceID="ObjectDataSource2" DataTextField="Col001" 
DataValueField="Col001"                onselectedindexchanged="ListBox1_SelectedIndexChanged"></asp:ListBox>
</td>

little bit further down...

[Update Panel code]
<td colspan="3">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblLeads" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="ListBox1" />
</Triggers>
</asp:UpdatePanel>
</td>

[Code Behind for ListBox]
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string myLeads = "";

            for (int i = 0; i < ListBox1.Items.Count; i++)
            {
                if (ListBox1.Items[i].Selected)
                {
                    myLeads += ListBox1.Items[i].Value + ", ";
                }
            }

            if (myLeads.Length > 0)
            {
                myLeads = myLeads.Substring(0, myLeads.Length - 2);
            }

            lblLeads.Text = myLeads;
        }

Open in new window

0
jljaleahy
Asked:
jljaleahy
  • 2
  • 2
1 Solution
 
Shaun KlineLead Software EngineerCommented:
List boxes do not cause a postback unless you specifically mark them with the AutoPostBack="True" property.
0
 
jljaleahyAuthor Commented:
Shaun,

Thanks for the quick response. I set that propert to true before, but failed to mention it in the post.

the problem with setting it to true, is that I get a regular postback, not an AJAX type postback, which I am looking for.

Any help is appreciated.

Thansk again.
0
 
Shaun KlineLead Software EngineerCommented:
Instead of a postback trigger, try an asyncpostback trigger.
<asp:AsyncPostBackTrigger ControlID="ListBox1" EventName="SelectedIndexChanged" />
(This worked with the asp.net script manager.)
0
 
jljaleahyAuthor Commented:
Thanks Shaun,
I had tried the Async but not in conjuction with the autopostback = true.

Thanks again.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now