I am new to MVC 3. I have a page (for eg: "Master Page") where I have some dropdown boxes to select values and click on "Go" button (type = "Button"). Based on the selection, I am filing a grid. One of the columns in the grid will have hyperlink. Upon clicking the hyperlink, opens another page (for eg: "details Page") to display other details. Now if the user click on browser back button, the values in the controls of "Master Page" is empty. How to retain the values in the dropdown boxes and grid on "Master Page".
You're relying on behavior of the browser. Some browsers can keep this data, others don't. So it's up to programmer decide where the data must be stored. In common cases you can use the following approaches:
If you make a wizard, just make some div's hidden (you will keep wizard's steps in there), and make your own next/back buttons inside of your wizard. When the user tries to go back and next, he won't go to another page, but will switch between steps via JavaScript inside of one page (all data will be kept).
You can do the same, but keeping your data on the server. In this case, by clicking on the button, your data will be kept in the database. And will be reloaded again when the user goes back.
You can manually save data to cookies. It's okay if you have small amounts of data to be kept.
Related
Vaadin loses the content on pressing the browser back button. If I have populated a table and if I go back to that page, the page is empty again. How can I save state of pages so that when I go back to them using browser back button they're in the state I left them.
I am using Navigator currently.
I am basically uploading an excel sheet using Upload component, and populating my table on the same page using table.additem(). I have a functionality that when user clicks on a row of the table, user navigates to the next page, but when I press the browser back button then the table is gone, and the upload shows no document selected.
The navigation updates Application/#!Main/ the variable part changes.
I just want my application to retain the state as it would do with a refresh.
I found the same issue. You should add scope #UIScope to your views, in this scope session works, and state will be saved.
I have an mvc app where I pass a list to a view. In a most click, I want to be able to render the next item in the last but am having trouble figuring out how to do that efficiently. My approach originally was to use an index i but I realized that one the page is rendered, accessing my model last at i will always leaf to the same result since that item in the list is rendered on page load and can't just be accessed dynamically. Any insight to an approach for this problem?
The model can't be accessed as it's only used on the server side.
There are a few ways of solving the problem, you can use Knockout.js or similar client side view model components, once the user click on the button just render then next item from the knockout model.
Or use AJAX to retrieve the next value from the back end and then render it to the screen.
Or generate the whole screen and just hide all items from the user and then display them once the user clicks the button
This is my scenario
I have an view(page) with list of items, a user could select single or multiple items from this page and click on a "Add to Group" button. Then a modal dialog(JQuery dialog) will be shown, from that he could select group, then press the add button. Which causes the items selected in the parent page is added to that particular group.
So, which is the best way to pass the selected items to the modal pop-up?
Though the query string ? - what happens if the no:of items selected is large, will the url support that much characters
Keep the list in the parent page in a javascript variable and return the selected group from the modal pop-up?
Or is there is any other better option?
Thanks,
Rajeesh
2a. There is no "parent" page; modal dialog is part of the same page as selected items. Therefore on "OK" function from the dialog you can go through the checked items and do whatever you want, including POSTing to the server. It's not clear from your post whether "adding items to the group" happens on the server or client
I've got a big ViewModel for a ContactViewModel with several addresses (default, invoice, delivery). This ContactViewModel I would like to edit within a DefaultAddress tab, etc. and I would like to know how to handle this without JavaScript? Is this possible?
Tell me if I'm off base here;
The way i think i'd approach this is to create a partial view which takes a list. the partial view would itterate through the list and create another partial view which is the tab.
on click of the tab i'd do a postback and store the clicked tab. this id then becomes the active tab.
when i come back to rebuild my page, the partialview for the actual tab would need to check to see if it's active and then make itself visible. if not visible then simply render nothing maybe.
This can be done with CSS. Here is an example: http://www.alistapart.com/articles/slidingdoors/
The selected tab/view will need to be rendered on the server. I can see each tab being a link, when the link is clicked the correct view and selected tab is returned.
Some of the css tabs don't work correctly in IE6. I'm not sure if the above link is one of them.
I am working on MVC with C#.
I have 2 radio buttons. On selecting first radio button, a textbox will be shown which allows to enter date values.
<%= Html.TextBox("ReceivedDate")%>
on selecting the second radio button, the textbox gets hidden.
For the first time, when i select first radio button and entered date and clicked Next to navigate to next page and came back to this page again and clicked second radio button and clicked Next to continue and again i came back to this page and without changing any option click continue, its not allowing to navigate and shows an error.
A value is required.
Which means the ModelState validating the hidden controls also.
Please suggest how to control it
Instead of hiding it remove the element from the DOM and reinsert it if the first item is selected again. Another way would be to change the name of the input control to something else (a key not present in your model data) when the first item is not selected.
Validating hidden input types is a good thing, i often use them to synchronize data from complex controls (like a treeview with checkboxes). An input type with a hidden css style doesn't make it not submit with the form it belongs too.