Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Ajax Triggers for DropDownList don't fire

Reply
Thread Tools

Ajax Triggers for DropDownList don't fire

 
 
Troy Donavan
Guest
Posts: n/a
 
      12-22-2006
I'm trying to get a partial page (Ajax style) update when the selection of a
DropDownList changes. I'm not having much luck. I will continue plugging
away at the sample applications in hopes of finding some hints, but
meanwhile, if someone could point out to me what I am doing wrong, I would
appreciate it. Here is a page with three controls on it. They are for
selection of Country, State and Locality. The idea is that when one chooses
the country, the possible selections for state (region) would then update and
similarly for localities.

Let me know if you can spot my problem. Here is the code:


<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.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" />
<div>

<asp:UpdatePanel ID="UPCountry" runat="server">
<ContentTemplate>

<aspropDownList ID="DDCountry" runat="server"
style="z-index: 100; left: 500px; position: absolute; top: 100px; width:
200px" OnLoad="DDCountry_Load">
</aspropDownList>

<aspropDownList style="Z-INDEX: 100; LEFT: 500px; WIDTH:
200px; POSITION: absolute; TOP: 130px" id="DDState" runat="server"
OnLoad="DDState_Load">
</aspropDownList>

<aspropDownList style="Z-INDEX: 100; LEFT: 500px; WIDTH:
200px; POSITION: absolute; TOP: 160px" id="DDLocality" runat="server"
OnLoad="DDLocality_Load">
</aspropDownList>
</ContentTemplate>
<triggers>
<asp:AsyncPostBackTrigger ControlID="DDState"
EventName="TextChanged"></asp:AsyncPostBackTrigger>
<asp:AsyncPostBackTrigger ControlID="DDCountry"
EventName="TextChanged"></asp:AsyncPostBackTrigger>
</triggers>
</asp:UpdatePanel>

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


--
Troy Donavan
 
Reply With Quote
 
 
 
 
technoGirl
Guest
Posts: n/a
 
      12-24-2006
Troy,

Shouldn't you be using OnSelectedIndexChanged =
DDCountry_SelectedIndexChanged for your drop downs??? Since you want a
ajax style functionality??
Tina

Troy Donavan wrote:
> I'm trying to get a partial page (Ajax style) update when the selection of a
> DropDownList changes. I'm not having much luck. I will continue plugging
> away at the sample applications in hopes of finding some hints, but
> meanwhile, if someone could point out to me what I am doing wrong, I would
> appreciate it. Here is a page with three controls on it. They are for
> selection of Country, State and Locality. The idea is that when one chooses
> the country, the possible selections for state (region) would then update and
> similarly for localities.
>
> Let me know if you can spot my problem. Here is the code:
>
>
> <%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb"
> Inherits="_Default" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.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" />
> <div>
>
> <asp:UpdatePanel ID="UPCountry" runat="server">
> <ContentTemplate>
>
> <aspropDownList ID="DDCountry" runat="server"
> style="z-index: 100; left: 500px; position: absolute; top: 100px; width:
> 200px" OnLoad="DDCountry_Load">
> </aspropDownList>
>
> <aspropDownList style="Z-INDEX: 100; LEFT: 500px; WIDTH:
> 200px; POSITION: absolute; TOP: 130px" id="DDState" runat="server"
> OnLoad="DDState_Load">
> </aspropDownList>
>
> <aspropDownList style="Z-INDEX: 100; LEFT: 500px; WIDTH:
> 200px; POSITION: absolute; TOP: 160px" id="DDLocality" runat="server"
> OnLoad="DDLocality_Load">
> </aspropDownList>
> </ContentTemplate>
> <triggers>
> <asp:AsyncPostBackTrigger ControlID="DDState"
> EventName="TextChanged"></asp:AsyncPostBackTrigger>
> <asp:AsyncPostBackTrigger ControlID="DDCountry"
> EventName="TextChanged"></asp:AsyncPostBackTrigger>
> </triggers>
> </asp:UpdatePanel>
>
> </div>
> </form>
> </body>
> </html>
>
>
> --
> Troy Donavan


 
Reply With Quote
 
 
 
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      12-25-2006
Hi Troy,

As Tina pointed out, if you want to update second DropDownList when the
first one changes, you need to handle the first one's SelectedIndexChanged
event instead of the Load event. Also you need to set the first
DropDownList's AutoPostBack to true:

<asp:UpdatePanel ID="UPCountry" runat="server">
<ContentTemplate>
<aspropDownList ID="DDCountry" runat="server"
Style="z-index: 100; left: 500px;
position: absolute; top: 100px; width: 200px"
OnLoad="DDCountry_Load"
OnSelectedIndexChanged="DDCountry_SelectedIndexCha nged" AutoPostBack="true">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
</aspropDownList>



Protected Sub DDCountry_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
DDState.Items.Clear()
Dim s As String = DDCountry.SelectedItem.Text
For i As Integer = 1 To 2
DDState.Items.Add(s + "_" + i.ToString())
Next
End Sub



Hope this helps.

Sincerely,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Troy Donavan
Guest
Posts: n/a
 
      12-27-2006
>AutoPostBack="true"

What a wonderful concept!!! Thank you very much!

--
Troy Donavan


"Walter Wang [MSFT]" wrote:

> Hi Troy,
>
> As Tina pointed out, if you want to update second DropDownList when the
> first one changes, you need to handle the first one's SelectedIndexChanged
> event instead of the Load event. Also you need to set the first
> DropDownList's AutoPostBack to true:
>
> <asp:UpdatePanel ID="UPCountry" runat="server">
> <ContentTemplate>
> <aspropDownList ID="DDCountry" runat="server"
> Style="z-index: 100; left: 500px;
> position: absolute; top: 100px; width: 200px"
> OnLoad="DDCountry_Load"
> OnSelectedIndexChanged="DDCountry_SelectedIndexCha nged" AutoPostBack="true">
> <asp:ListItem>1</asp:ListItem>
> <asp:ListItem>2</asp:ListItem>
> </aspropDownList>
>
>
>
> Protected Sub DDCountry_SelectedIndexChanged(ByVal sender As Object,
> ByVal e As System.EventArgs)
> DDState.Items.Clear()
> Dim s As String = DDCountry.SelectedItem.Text
> For i As Integer = 1 To 2
> DDState.Items.Add(s + "_" + i.ToString())
> Next
> End Sub
>
>
>
> Hope this helps.
>
> Sincerely,
> Walter Wang ((E-Mail Removed), remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
> promptly.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax UpdatePanel w/Progress Template and Triggers Scott M. ASP .Net 1 03-17-2009 05:59 PM
Ajax - ascx and updatepanel triggers =?Utf-8?B?QWxleA==?= ASP .Net 0 04-26-2007 12:42 PM
AJAX.NET triggers don't fire Troy Donavan ASP .Net Web Controls 0 12-19-2006 07:33 AM
select dropdownlist triggers click on row =?Utf-8?B?RGFiYmxlcg==?= ASP .Net 1 04-04-2006 10:43 PM
Re: URGENT!!!!!!!!!!!!!!!!Can Triggers fire to execute DTS Package????????? bruce barker ASP .Net 1 04-02-2004 08:56 PM



Advertisments