Click here to Skip to main content
15,905,679 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Opinions needed on "shared" keyword Pin
Dave Kreskowiak12-Jan-12 9:38
mveDave Kreskowiak12-Jan-12 9:38 
GeneralRe: Opinions needed on "shared" keyword Pin
Luc Pattyn12-Jan-12 8:34
sitebuilderLuc Pattyn12-Jan-12 8:34 
GeneralRe: Opinions needed on "shared" keyword Pin
nlarson1112-Jan-12 8:51
nlarson1112-Jan-12 8:51 
AnswerRe: Opinions needed on "shared" keyword Pin
Eddy Vluggen12-Jan-12 10:40
professionalEddy Vluggen12-Jan-12 10:40 
GeneralRe: Opinions needed on "shared" keyword Pin
nlarson1113-Jan-12 2:44
nlarson1113-Jan-12 2:44 
GeneralRe: Opinions needed on "shared" keyword Pin
Eddy Vluggen13-Jan-12 6:34
professionalEddy Vluggen13-Jan-12 6:34 
QuestionDynamic dropdowns enable without post back Pin
byka12-Jan-12 6:31
byka12-Jan-12 6:31 
AnswerRe: Dynamic dropdowns enable without post back Pin
DannyStaten12-Jan-12 10:39
DannyStaten12-Jan-12 10:39 
If your dropdowns are truly dynamic, then you are going to have to make a request from the server to get the next dropdown's values. In the most technical sense, that is a post to the server. I assume that you mean that you don't want to do a page refreshing style of a postback. In other words, you want an ajax call to load the data for the next dropdown.

You have two general schools of thought you can go with:

1. UpdatePanel. This lets you run things through your server side events, and it disguises the postbacks so they don't make the page refresh. Pros are that it is simpler to implement. You basically can implement it as you would if you wanted the dropdowns to do a postback to load the next one. Then you wrap the dropdowns in an update panel, and set a few things and you are done. The update panel makes all those postbacks become ajax calls that don't refresh the page.

Cons are that it is far less efficient in terms of bandwidth and server resources, and it can lead to some difficult debugging if you aren't familiar with the .net life cycle. Update panels result in a massive amount of auto generated javascript and additional markup being rendered to the browser which is not really ideal. Also, update panels only work for web forms applications, and are not available for MVC. I assume from what I saw in your question that you are doing web forms.

2. Ajax calls to web methods. Pros are that this is clean and efficient. You save tons on bandwidth consumption which can be a big deal for slow connection users. You also take a much lighter load on the server resources, which is a big deal for higher traffic solutions. You also are in much better control of what is rendered to the browser. Cons are that you have to know javascript a lot better than you would with update panels, and you have to take care of a few specifics that update panels abstract or take care of for you.

I vastly prefer the 2nd option. If you go with the ajax option, then I can give you some additional pointers and things to look out for. I would suggest you use jquery and set up something like:

in javascript:
$("#myDropDown1Id").change(function(){

$.ajax({...//look at jquery.com for your specifics. You set your address, and send your parameters
success:function(data){
//receive the data from your server and populate dropdown2

},
error:function(data){
//notify the user in some way
});//end of .ajax
});//end of change function


Then you need to have a function exposed to be called as a web service. In web forms, you can have a method on your code behind and annotate the method as a WebMethod, or you can add a web service to the project and have methods exposed there. The json parameters you pass in javascript must match the case of your parameters on the server side exactly, which can be a gotcha. Order of the parameters is also important I believe.

If you do it via an ajax call then your web forms code behind won't have wired up change events for your dropdown. Rather you have web methods exposed that take a value and return data to the client.

The other thing to look out for on web forms is that if you are building dropdowns client side, the web forms security will get mad at you when you do finally submit. You will get an error that your values weren't registered for postback. It is webforms effort to prevent malicious javascript from injecting invalid options into the values a dropdown can send back.

To fix that you need to call a registerforpostback method associating every value you send back in your web service with that dropdown. That one can be a pain to work the nuances out.

So there is a lot involved, and I obviously didn't give you a full explanation on every aspect. I hope I gave enough that you can google for details and get it working. Good luck.
QuestionChanging default value of a property of a control (DataGridView). Pin
priyamtheone12-Jan-12 3:16
priyamtheone12-Jan-12 3:16 
Answere: Changing default value of a property of a control (DataGridView). Pin
Simon_Whale12-Jan-12 3:41
Simon_Whale12-Jan-12 3:41 
QuestionRe: e: Changing default value of a property of a control (DataGridView). Pin
priyamtheone14-Jan-12 3:27
priyamtheone14-Jan-12 3:27 
AnswerRe: Changing default value of a property of a control (DataGridView). Pin
Wayne Gaylard12-Jan-12 3:47
professionalWayne Gaylard12-Jan-12 3:47 
QuestionDirectShowLib Adjust Camera Brightness Pin
ggoutam711-Jan-12 17:31
ggoutam711-Jan-12 17:31 
QuestionVB2010 Serial Port Tutorial? Pin
JDBravo11-Jan-12 9:19
JDBravo11-Jan-12 9:19 
Answercheck this article out Pin
David Mujica11-Jan-12 10:02
David Mujica11-Jan-12 10:02 
GeneralRe: check this article out Pin
JDBravo11-Jan-12 10:11
JDBravo11-Jan-12 10:11 
AnswerRe: VB2010 Serial Port Tutorial? Pin
Luc Pattyn11-Jan-12 11:02
sitebuilderLuc Pattyn11-Jan-12 11:02 
GeneralRe: VB2010 Serial Port Tutorial? Pin
JDBravo11-Jan-12 11:48
JDBravo11-Jan-12 11:48 
AnswerRe: VB2010 Serial Port Tutorial? Pin
Luc Pattyn11-Jan-12 12:09
sitebuilderLuc Pattyn11-Jan-12 12:09 
GeneralRe: VB2010 Serial Port Tutorial? Pin
JDBravo12-Jan-12 4:15
JDBravo12-Jan-12 4:15 
GeneralRe: VB2010 Serial Port Tutorial? Pin
JDBravo12-Jan-12 6:19
JDBravo12-Jan-12 6:19 
GeneralRe: VB2010 Serial Port Tutorial? Pin
Simon_Whale12-Jan-12 6:26
Simon_Whale12-Jan-12 6:26 
GeneralRe: VB2010 Serial Port Tutorial? Pin
JDBravo12-Jan-12 6:38
JDBravo12-Jan-12 6:38 
AnswerRe: VB2010 Serial Port Tutorial? Pin
Luc Pattyn12-Jan-12 6:30
sitebuilderLuc Pattyn12-Jan-12 6:30 
GeneralRe: VB2010 Serial Port Tutorial? Pin
JDBravo12-Jan-12 6:46
JDBravo12-Jan-12 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.