Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > cannot fire up dropdownlist's SelectedIndexChanged

Reply
Thread Tools

cannot fire up dropdownlist's SelectedIndexChanged

 
 
Daniel
Guest
Posts: n/a
 
      06-08-2004
Is there any other way can override this event, like javascript onchange
added to the attribute of this dropdownlist?

Thanks


 
Reply With Quote
 
 
 
 
Shaun C McDonnell
Guest
Posts: n/a
 
      06-08-2004
Set the AutoPostBack property to "true" on the DropDownList.

Shaun


"Daniel" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Is there any other way can override this event, like javascript onchange
> added to the attribute of this dropdownlist?
>
> Thanks
>
>



 
Reply With Quote
 
 
 
 
Daniel
Guest
Posts: n/a
 
      06-08-2004
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" <(E-Mail Removed)-spammers-stop.now> wrote in
message news:%(E-Mail Removed)...
> Set the AutoPostBack property to "true" on the DropDownList.
>
> Shaun
>
>
> "Daniel" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Is there any other way can override this event, like javascript onchange
> > added to the attribute of this dropdownlist?
> >
> > Thanks
> >
> >

>
>



 
Reply With Quote
 
martin
Guest
Posts: n/a
 
      06-09-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)-spammers-stop.now> wrote in
> message news:%(E-Mail Removed)...
> > Set the AutoPostBack property to "true" on the DropDownList.
> >
> > Shaun
> >
> >
> > "Daniel" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > Is there any other way can override this event, like javascript

onchange
> > > added to the attribute of this dropdownlist?
> > >
> > > Thanks
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
avnrao
Guest
Posts: n/a
 
      06-09-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)-spammers-stop.now> wrote in
>> message news:%(E-Mail Removed)...
>> > Set the AutoPostBack property to "true" on the DropDownList.
>> >
>> > Shaun
>> >
>> >
>> > "Daniel" <(E-Mail Removed)> wrote in message
>> > news:%(E-Mail Removed)...
>> > > Is there any other way can override this event, like javascript

> onchange
>> > > added to the attribute of this dropdownlist?
>> > >
>> > > Thanks
>> > >
>> > >
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      06-09-2004
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>
<aspropDownList 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>
</aspropDownList></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




 
Reply With Quote
 
Daniel
Guest
Posts: n/a
 
      06-09-2004
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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>
> <aspropDownList 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>
> </aspropDownList></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
>
>
>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      06-10-2004
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


 
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
cannot fire up selectedindexchanged of the dropdownlist Daniel ASP .Net 2 06-09-2004 07:15 AM
Getting SelectedIndexChanged to fire again ]-[aTc]-[ ASP .Net 1 02-24-2004 05:42 PM
selectedindexchanged won't fire when I have an ascx on page Brent Burkart ASP .Net 1 01-23-2004 05:24 PM
Re: SelectedIndexchanged won't fire yyt ASP .Net 1 12-21-2003 07:20 AM
SelectedIndexChanged won't fire Brent Burkart ASP .Net 3 11-26-2003 05:45 PM



Advertisments