Video Transcript
So we are getting there, we are definitely on the right tract, but really what we need is they build different automatic Postback so that as soon as we change like in here, it automatically Postback into the server and therefore automatically generates the selected index change event, so that we can display the appropriate countries for that region.
To do that, what we need to do is go back to our ASPX page and each of the controls that we want to automatically Postback as soon as a change clears. So for example, the name text box, if you look at the properties, there is a property called auto Postback. And that moment and by default, it set to false so we need to set it to true. And by doing that, the text change event will occur automatically without clicking the update button and likewise for the telephone number. We will set auto Postback property to true and for the region, we will set it to true and for the county list, we will set it to true.
Okay. Now, just out of interest, if you look at the source code behind the page, you can see for example for the drop down list, it is added the auto Postback equals true property. So, we could have just type this property in here directly if you go into two.
Okay, let us run the application and see if it works better now. So name, Helen Smith, I just made that one up. Oh look at that, straight away, as soon as I click that to the text box, into the telephone number, straight away, it posted back to the server and triggered the on text change event and displayed the person's name in the business card. So that is very promising, telephone number, 12345 and down the list, carved out into different again.
Now look, this is not per keystroke. There is no way of capturing on keystroke events in then ASP.net web application and that is probably a good thing. I mean, can you imagine if every time you press the key, it posted back to the web server, the performance would be terrible. You have to transfer focus into different control in order to generate the on- text event, and obviously, if you are in the text control and you do not change the text and then you tab out, then no event occurs.
So the region, see that Helen works in the Asia-Pacific region, that trigger the Postback so the countries here are India, Japan and Australia. So let us select India. Okay, good. So that concludes our example here.
So what we have seen is how to handle some of the non-travel events as well as handling click events that you have on buttons. So for example if we go back into this design view, we know how handle click events on buttons and in this example, we have also seen how to handle events such as text change and selected index change on some of our other controls. We have also seen how the auto Postback mechanism enables us to trigger the events automatically instead of have to wait until a button get clicked.
So we are getting there, we are definitely on the right tract, but really what we need is they build different automatic Postback so that as soon as we change like in here, it automatically Postback into the server and therefore automatically generates the selected index change event, so that...
click to read more