Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

C# - event not firing

I have two events:

1. btn1_Click (firing okay, but...)
2. cboRegion_OnTextChanged (is not firing.)

The html/aspx lines for each event shown just above the events.

Question: How can I change the event for cboRegion so it would fire as well?

Thank you.
<asp:Button ID="btn1"  GroupName="cmdOpt" Name="opt" runat="server" Text="1" TabIndex="1" onclick="btn1_Click"   />

protected void btn1_Click(object sender, EventArgs e)
    {
        Session["strBtn"] = strBtn;
        // Response.Redirect("Default2.aspx",false);
    }
------------------------------------
       <asp:DropDownList ID="cboRegion" runat="server" Width="83" OnTextChanged="cboRegion_OnTextChanged" >
            <asp:ListItem Text="Region 1" Value="1"  />
            <asp:ListItem Text="Region 2" Value="2"  />
            <asp:ListItem Text="Region 3" Value="3"  />
        </asp:DropDownList>

    protected void cboRegion_OnTextChanged(object sender, EventArgs e)
    {
        Session["Year"] = "3333";
        // Response.Redirect("Default2.aspx",false);
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Raghu Mutalikdesai
Raghu Mutalikdesai
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Eghtebas

ASKER

Hi Raghu for coming to my rescue,

That was excellent point because the users just select not change values. This is what is happening now:

I select a different year but its event doesn't fire. However, when I click on the button, all of sudden it stops at the break point in cboRegion_Change event.

Question: What is the explanation for this?

Thanks,

Mike
Possibly, one difference between the button and the rest is buttons submit while the other may not do that. Does this kind of make sense to you?

If so, then how can we get some action from the controls other than buttons?
I got it, I need to set:

AutoPostBack="True"

in those controls.
Well, you were too quick and you figured out the answer even before I looked at your comment! Thanks for accepting my answer.
I appreciate for the participation.

Mike
Hi Raghu,

I have couple of other questions now. Do you have some time to take a look at them? I will be glad to post the links for the questions here.

Mike
Sure. please post the questions. I will try to answer those.