Solved

C# - event not firing

Posted on 2014-07-27
9
529 Views
Last Modified: 2014-07-28
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

0
Comment
Question by:Mike Eghtebas
  • 6
  • 3
9 Comments
 
LVL 7

Accepted Solution

by:
Raghu Mutalikdesai earned 500 total points
ID: 40223479
Instead of OnTextChanged event, try using OnSelectedIndexChanged event.
OnSelectedIndexChanged="cboRegion_Change"

Open in new window

I am assuming user is not allowed to "type" in the drop down, and only "select"
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40223505
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
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40223512
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?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40223532
I got it, I need to set:

AutoPostBack="True"

in those controls.
0
 
LVL 7

Expert Comment

by:Raghu Mutalikdesai
ID: 40223538
Well, you were too quick and you figured out the answer even before I looked at your comment! Thanks for accepting my answer.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40223565
I appreciate for the participation.

Mike
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40223576
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
0
 
LVL 7

Expert Comment

by:Raghu Mutalikdesai
ID: 40223584
Sure. please post the questions. I will try to answer those.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40223604
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Windows app updating JSON file error. 9 39
How to force output to ascii 2 40
Json and ajax 1 22
ASP.net Moving Visual Studio 2015 project to 2017 2 41
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question