cbOperation_SelectedIndexChanged not invoked when a ComboBox was changed

R

Richard Lionheart

Hi,

I've got the following control defined in my .aspx file:

<asp:dropdownlist id="cbOperation" style="Z-INDEX: 102; LEFT: 162px;
POSITION: absolute; TOP: 77px" runat="server" Width="38px">
<asp:listitem text="?" value="0" />
<asp:listitem text="+" value="1" />
<asp:listitem text="-" value="2" />
<asp:listitem text="*" value="3" />
<asp:listitem text="/" value="4" />
</asp:dropdownlist>

I tried to intervene when the selection changed with the following code in
my .aspx.cs file:

private void cbOperation_SelectedIndexChanged(object sender,
System.EventArgs e)
{
tbResult.Text = "";
}

The TextBox tbResult did not get blanked out when I changed the selection.
A parallel routine, btnEquals_Click, succeeds in blanking the Result in
various circumstances.

I thought perhaps AutoEventWireup="false" might have something to do with
it, so I changed it to "true" and "True", but that made no difference.
Have I provided enough information here to allow you to make an educated
guess about what causes my problem? Should I post the entire .aspx and
..aspx.cs files?

Thanks in Advance,
Richard
 
M

Mike Robbins

Hi, Richard.

Try adding OnSelectedIndexChanged="cbOperation_SelectedIndexChanged" to
your DropDownList tag.

Mike
 
R

Richard Lionheart

Hi Mike,

That was great!! The debugger confirms that routine gets called. Thank you
very much for that guidance.

But it doesn't work the way I intended because the routine doesn't get
invoked immediately after the change in the List. It gets invoked only
after post-back initiated by a subsequent click on the "equals" button. I
doubt I can get the List to fire a post-back, so I assume I've got to add
some client-side scripting instead of the link I just added.

I assume I can stick the client-side script in the Head section of the .aspx
code. I'll poke around the web and my books to figure out how to do that.
If you have any hints about that I'd be grateful to get them from you.

Regards,
Richard Muller
 
M

Mike Robbins

Hi, Richard.

Add the AutoPostBack="True" attribute to your control.

Thanks,

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top