473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

cannot fire up dropdownlist's SelectedIndexChanged

Is there any other way can override this event, like javascript onchange
added to the attribute of this dropdownlist?

Thanks
Nov 18 '05 #1
7 6161
Set the AutoPostBack property to "true" on the DropDownList.

Shaun
"Daniel" <so*****@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Is there any other way can override this event, like javascript onchange
added to the attribute of this dropdownlist?

Thanks

Nov 18 '05 #2
Yes, i've done that, but still cannot fire up, there is a javascript
onChange on this dropdownlist, i wonder it will affect this.

Thanks.

"Shaun C McDonnell" <ms****@bellsouth.net-spammers-stop.now> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Set the AutoPostBack property to "true" on the DropDownList.

Shaun
"Daniel" <so*****@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Is there any other way can override this event, like javascript onchange
added to the attribute of this dropdownlist?

Thanks


Nov 18 '05 #3
try returning "true" from the dropdown list

<select ddl... onchange="myevent();return true;"

I noticed that I had to use this method on a checkbox that poste back.

make sure that true is returne before the call to the .net generated
javascript.

HTH

cheers

martin

"Daniel" <so*****@yahoo.com> wrote in message
news:OK**************@TK2MSFTNGP12.phx.gbl...
Yes, i've done that, but still cannot fire up, there is a javascript
onChange on this dropdownlist, i wonder it will affect this.

Thanks.

"Shaun C McDonnell" <ms****@bellsouth.net-spammers-stop.now> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Set the AutoPostBack property to "true" on the DropDownList.

Shaun
"Daniel" <so*****@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Is there any other way can override this event, like javascript onchange added to the attribute of this dropdownlist?

Thanks



Nov 18 '05 #4
you said you are adding it as an attribute..
if you are doing this..
DropDownList1.Attributes.Add("onchange","alert(2); return;");
make sure that you should not have the return status after your javascript
executes. remove the RETURN from above line.

asp.net spits out the html like this..
<select name="DropDownList1"
onchange="alert(2);return;__doPostBack('DropDownLi st1','')"..
so having return on onchange would not fire post back.

Av.

"martin" <St**************@yahoo.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
try returning "true" from the dropdown list

<select ddl... onchange="myevent();return true;"

I noticed that I had to use this method on a checkbox that poste back.

make sure that true is returne before the call to the .net generated
javascript.

HTH

cheers

martin

"Daniel" <so*****@yahoo.com> wrote in message
news:OK**************@TK2MSFTNGP12.phx.gbl...
Yes, i've done that, but still cannot fire up, there is a javascript
onChange on this dropdownlist, i wonder it will affect this.

Thanks.

"Shaun C McDonnell" <ms****@bellsouth.net-spammers-stop.now> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
> Set the AutoPostBack property to "true" on the DropDownList.
>
> Shaun
>
>
> "Daniel" <so*****@yahoo.com> wrote in message
> news:%2***************@TK2MSFTNGP10.phx.gbl...
> > Is there any other way can override this event, like javascript onchange > > added to the attribute of this dropdownlist?
> >
> > Thanks
> >
> >
>
>



Nov 18 '05 #5
HI Daniel,

I've also found some other former threads you posted discussing on this
problem. Since this is a strange behavior , I'd like to confirm some other
things:
1. Are there any other controls which can autopostback such as "TextBox" ,
"CheckBox" also suffering the problem?

2. Does this problem occur in many pages or just one particular page?

3. What about creating a new simple web project and a page to do the same
test?

Here is a test page I use to test on my side, please have a check to see
whether it works.

==================aspx page=====================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>AutoPostBack</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td>
<asp:TextBox id="TextBox1" runat="server"
AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="DropDownList1" runat="server"
AutoPostBack="True">
<asp:ListItem Value="aaa" Selected="True">aaa</asp:ListItem>
<asp:ListItem Value="bbb">bbb</asp:ListItem>
<asp:ListItem Value="ccc">ccc</asp:ListItem>
<asp:ListItem Value="ddd">ddd</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td>
<asp:ListBox id="ListBox1" runat="server" AutoPostBack="True">
<asp:ListItem Value="aaa">aaa</asp:ListItem>
<asp:ListItem Value="bbb">bbb</asp:ListItem>
<asp:ListItem Value="ccc">ccc</asp:ListItem>
<asp:ListItem Value="ddd">ddd</asp:ListItem>
</asp:ListBox></td>
</tr>
</table>
</form>
</body>
</HTML>

==============code behind=====================
Public Class AutoPostBack
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents DropDownList1 As
System.Web.UI.WebControls.DropDownList
Protected WithEvents ListBox1 As System.Web.UI.WebControls.ListBox

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.TextChanged
Response.Write("TextBox1 is AutoPostBack!")
End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Response.Write("DropDownList1 is AutoPostBack!")
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
Response.Write("ListBox1 is AutoPostBack!")
End Sub
End Class
================================================== ===

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx


Nov 18 '05 #6
Hi, steven

There is a listbox on the same page, on the design page, i double click
this, and in the code behind i have the below, and i make it autopostback
true.
Private Sub lstCTSUnit_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lstCTSUnit.SelectedIndexChanged

Response.Write("Test from Fei")

End Sub

It doesnot work!

Strange, AND i really need help!

Thanks!



"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:aT**************@cpmsftngxa10.phx.gbl...
HI Daniel,

I've also found some other former threads you posted discussing on this
problem. Since this is a strange behavior , I'd like to confirm some other
things:
1. Are there any other controls which can autopostback such as "TextBox" ,
"CheckBox" also suffering the problem?

2. Does this problem occur in many pages or just one particular page?

3. What about creating a new simple web project and a page to do the same
test?

Here is a test page I use to test on my side, please have a check to see
whether it works.

==================aspx page=====================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>AutoPostBack</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td>
<asp:TextBox id="TextBox1" runat="server"
AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="DropDownList1" runat="server"
AutoPostBack="True">
<asp:ListItem Value="aaa" Selected="True">aaa</asp:ListItem>
<asp:ListItem Value="bbb">bbb</asp:ListItem>
<asp:ListItem Value="ccc">ccc</asp:ListItem>
<asp:ListItem Value="ddd">ddd</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td>
<asp:ListBox id="ListBox1" runat="server" AutoPostBack="True">
<asp:ListItem Value="aaa">aaa</asp:ListItem>
<asp:ListItem Value="bbb">bbb</asp:ListItem>
<asp:ListItem Value="ccc">ccc</asp:ListItem>
<asp:ListItem Value="ddd">ddd</asp:ListItem>
</asp:ListBox></td>
</tr>
</table>
</form>
</body>
</HTML>

==============code behind=====================
Public Class AutoPostBack
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents DropDownList1 As
System.Web.UI.WebControls.DropDownList
Protected WithEvents ListBox1 As System.Web.UI.WebControls.ListBox

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Response.Write("TextBox1 is AutoPostBack!")
End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Response.Write("DropDownList1 is AutoPostBack!")
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
Response.Write("ListBox1 is AutoPostBack!")
End Sub
End Class
================================================== ===

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #7
Hi Daniel,

What about the demo page I provided in the last reply? Is it also not
working? If a new created page or even a simple page in a new created
project still suffering the problem. I'm afraid there must be some thing
incorrect with the ASP.NET 's installation on the machine. You can try use
the aspnet_regiis.exe tool in the
"{driver}:\WINDOWS\Microsoft.NET\Framework\v1.1.43 22" folder and type the
following command:

aspnet_regiis -u
aspnet_regiis -i

to uninstall and reinstall the ASP.NET on the machine. Thanks

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Russ | last post by:
Hi, I have found myself wanting to use an HTMLSelect control instead of a DropDownList so that I can programatically set the item colours in the list (not possible with DropDownList due to...
3
by: Brent Burkart | last post by:
I have a dropdownlist that won't fire .The autopostback is set to true and I do a ispostback check before population the ddl. Can anyone help please? Brent
2
by: CW | last post by:
Yes, Autopostback is true, and it doesn't make an iota of difference at all. HTML snippet and code (behind) snippet is as below: <asp:dropdownlist id="ddlLoginType" runat="server" Width="163px"...
2
by: Daniel | last post by:
I have a user control, a dropdownlist in it. I set autopostback="True" and OnSelectedIndexChanged="onSelect". In the code i have onSelect event, but just cannot fire it up? Need help, I...
6
by: srallen | last post by:
I have a simple page that has a dropdown with autopostback=true and onselectedindexchanged is set to a function that never gets called (checked during debug). This page is subclassed from custom...
3
by: Jim | last post by:
Hi All, Can someone tell me why the SelectedIndexChanged event does not fire? <form id="Form1" method="post" runat="server">
5
by: glenn | last post by:
Hi folks, If I want to select the first item in a DropDownList, I need to first select any item other than the first item and then next I select the first item which will then fire an event...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
7
by: Damien | last post by:
Hi guys, I'm trying to learn ASP.NET and got a problem with DroDownList... SelectedIndexChanged doesn't fire. Maybe you'll be able to suggest something. I think it may be connected with the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.