I am Having two dropdowns. based on the selection of one the other dropdown must be filled. Using Ajax is one way but some times it takes time to load the second dropdown.
How to avoid this ?
Is any thing like i pull all the data and do all manipulations at client side and shown instead using server resource and ajax ?
You could preload several hidden dropdowns and then display the appropriate one when the first dropdown is selected.
you can preload all the values (assuming they are not too many, say <1000) and then populate the second dropdown with a script, not hitting the server again.
Related
In my application, I have a list box(list of stores), Add and Remove buttons and another list box (selected stores).
I have Following requirements:
1. On click of Add button, copy selected items from the master stores list to the selected store list and clear the selection from master store list.
2. On Click of Remove button, remove the selected stores from the selected stores list.
I have added my master store list box and selected store list boxes to 2 different update panels and added triggers for each of the update panel. Things are working fine but one thing I have observed that it is taking unusually long to move selected stores from master list to selected list. I have around 5000 entries in the master list of stores.
If I remove the update panel for master store list, things are normal but I am not able to clear the selection. Am I doing something wrong? Is there a way to clear selection of listbox outside the update panel.
It sounds like your using UpdatePanels to move ListItems between 2 ListBox controls. This creates a overhead as each time you trigger the 'add' event it has to postback and render the UpdatePanel again (including the viewstate).
Have you looked into using jQuery to move your list items between your ListBox controls thus all the moving between boxes is handled by the browser. This will speed up the experience for the user?
You should also be able to use jQuery to clear the selection. If you can provide me a little snippet of your markup I can help you get it written up (or shoot me a message).
Brian =)
A form contains 2 cascading dropdowns. When an item is selected in the first dropdown, jQuery retrieves a list (json) from the server and fills the 2nd dropdown.
The user posts the page to the server, and when the page is returned the dropdown is empty because its not stored in viewstate.
What do you do in this situation? Is this the point where cascading dropdowns using jQuery and trying to make your page a little more stateless gets tedious?
You could always just set it up to pull the json from the server on page load as well, assuming that the first dropdown list has an item selected. The other option would be to pre-fill the second dropdown server-side if you know that the first dropdown has a value.
This may be silly, but trying to do a dual list box in ASP.Net MVC. I have the client side part working fine with options moving back and forth, but what I would like is for the person to be able to save when they are done. This means I have to post all of the values in the "selected" list box. I don't want to rely on the user leaving the items selected, so do I have to pre-select them using the onsubmit of the form or the onclick of the button? Or am I missing something obvious?
I would use jQuery to get the list items and submit them as a custom postback
gridview has 20 pages. The user is see first gridview page . He decide to apply highlite style using jquery on few row . Now he move to second page . He apply style this page too. Now when he go back to first page, he cannot see row with style he apply before he move to page 2.
How to store state of the rows style when user moving on pages? Perdon my English
Use a cookie to store highlighted rows on a given page. Hook up to a event on which highlighting takes place (click?) and add a code to rewrite a cookie with currently selected rows. When you will be printing the table just read the cookie and restore selections based on the value stored in it.
I would save the highlighted row id's in a hiddenfield. Pageing causes a Postback! Also you need some javascript code to re-highlight the fields.
If can afford to make the solution less efficient, I would change the highlight method so that in runs server side with a post back instead of using JavaScript and then put the GridView in a UpdatePanel.
Also remember to use DataSource object (e.g. ObjectDataSource) instead of binding your data manually using .DataBind() in the code behind. This should ensure that you don't rebind the data on every post back.
This is what I'm doing: Using jquery, I'm popping up a "form" over the page that lets the user search for branches of the company and select the one they want. When the form pops up, they can type in a textbox, and it will do AJAX requests back to the server to return the top n results for what they've entered, and those results will be put into a list for them. I want the user to be able to select one by clicking a link that says "select" or something, and at that point I want it to do a PostBack have the Branch Selector control that this is in change it's SelectedBranch property to the newly selected branch. I've got this all working right now with a hard coded list of LinkButtons, but how do I do the same thing with a dynamic list of links inserted with jquery?
Look at the HTML that gets emitted for your hard coded LinkButtons. You'll see that each one calls the JavaScript __doPostBack function when clicked. I believe this function takes two arguments: a control ID and an extra command argument you can use for your own purposes.
I would suggest adding a single control to the page whose only job is handling events for the dynamic links. Then, when you are creating the links with jquery, make each one call __doPostBack, passing the event handling control's ID for the first argument and some other string for the second argument that identifies which link was clicked. In the Click event for the handling control, look at the second argument value and do what you need to do.
The short answer is... you don't.
ASP.NET relies on the Viewstate for the current state of the controls, including items in a DropDownList or similar control. Dynamically updating a list on the client will not modify the viewstate, so will not be available on the back end.
The general workaround for this is to just add a hidden field which updates/stores the current selection via js on the client side. Then read it from this field on the backend rather than List.SelectedValue.