Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDown Event not firing 2

Status
Not open for further replies.

RonRepp

Technical User
Feb 25, 2005
1,031
US
Hi all:

I'm really used to Windows, so when working with an ASP page, I have 2 dropdowns. I is state, the other abbreviation. When a user chooses the state, I want the abbreviation's index = state's abbreviation.

Code:
Protected Sub ddState_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddState.SelectedIndexChanged
        ddState0.SelectedIndex = ddState.SelectedIndex
    End Sub

I put a breakpoint there, and it's not even firing.

What am I missing?

Thanks,

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
Ron asp is not asp.net. (which in turn is not webforms). right now you are generating html using the webforms html engine. This is the most common and, unfortunately default, engine for creating websites using the .net framework.

webforms is great for very simple websites. if there is no to limited logic and you are not concerned with the quality of the html output webforms will work. webforms was designed to give win app developers a familiar environment to create websites. This is why postback, viewstate, the page life cycle and events exist in webforms.

the essence of web development is actually much simpler than that. you have a request and a response. the request contains a series of string/string pairs that contain the user input. and response is text (usually html) back to the client. there is no state, not "postback", or anything like that.

as a side note webforms is not asp.net. asp.net is a framework for responding to http requests. webforms requires asp.net, but asp.net does not require webforms. This is why other html frameworks are possible. Castle.Monorail and MS MVC are alternatives to webforms. And from there you have alternatives to render the html output: nvelocity, spark, brail, aspview, webforms (but not the webforms like postback webforms).

ok enough background information... as for your problem.
the problem probably is in the aspx file. by default a dropdownlist in webforms will not postback automatically. so you need to set the AutoPostback property to true. another reason is the dropdownlist may not be associated to the handler you provided. the markup should look something like this
Code:
<asp:dropdownlist ... autopostback="true" onclick="ddState_SelectedIndexChanged" />



Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
webforms is great for very simple websites. if there is no to limited logic and you are not concerned with the quality of the html output webforms will work.
Not necessarly true. That is opinion, not fact.
I work for a major realty company with a very complex website and other large internal systems. That being said, webforms are just fine.
 
Jason, that worked.

JBenson, I've followed your code a zillion times in these threads, and you have truly been helpful to me over the years.

I appreciate both replies, but I'm more confused than ever. I bought 2008 because everyone said creating a functional website was so much easier.

I think I should stick to WinForms...I can barely do that.

Thanks,


Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
there is no IDE for making great applications. that is done by applying sound patterns and principles from OOP and no IDE can do that.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
I think the light bulb just went on.

Thanks again,


Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.

My newest novel: Wooden Warriors
 
I'm glad I have helped you over the years :)
As Jason said it's not the IDE. An IDE can help speed things along, but you need to have good skills behind the app.
The problem here is you have to decide what kind of application you need. Sometimes windows applications are better, sometimes it makes more sense to have a web app. It all depends on the audience, logistics, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top