Blazor Navigation Back Casue page to re render - c#

I am using Blazor, I have a page shows a list of products I scroll down to s specific product and click it and go to product details, but when the user return back by browser back the product list page is re rendered and so the user see the product list from the first Item and loose where he was, and also it refreshes the list so it me need some time to render, is there any way to prevent this and make it normal back Navigation

I would look into the lifecycle methods that you have to the page. What is probably happening is every time you navigate to a product list page (a component) it loads the product list for the first time. Then when you click on the product list, you navigate to another page.
To get the experience you want you'll want to somehow save the scroll position of on the Product List page. OR you could just use a modal to surface the product Or another way to show the Product Details without navigating out of the Product List page.

Related

How do I save the data on a user control before switching to a different one?

I have a WPF Application with different user controls. Each of them can be accessed by clicking a button on the left side. My issue is, when I am in one of the user controls and filling out the data in textboxes, combo boxes etc, I may have to stop it mid way and click on another user control. While doing that, I need to keep the data in the previous user control intact so that when I return to the first user control, the data should be present in all the controls before I left it. How do I achieve this? Here's a sample picture of how my application looks like:
Picture Credit: https://rachel53461.wordpress.com/2011/12/18/navigation-with-mvvm-2/
From the picture, if I am in the Products Page, I might have several text boxes with data entered in there. For a variety of reasons, I may have to step away from this and click on Home Page or some other page , do some work there and return back to the Products page. When I return, I need the data to be present as is when I left it.
Thanks in Advance
You must have create a ViewModel to each diferent user control.
ViewModel remains in memory until you process that or make a diferent process.
For Example you hava a User control for your Main Page, that's mean you have a view (MainPageView) of your user control for your main page, that view belong to a ViewModelMainPage.
For Products you maybe have a ProductView, that's belong to ViewModelProducts.
You must create a ManagerViewModel to manage the view for diferents user control.

Updating Model inside of view

I've been working on a photography page for a while now. Now I've tried to create a page on which user will upload photos to database.
I wanted to give the user an option of selecting photo categories on the create/upload page using checkboxes. I wanted to use a viewmodel with list of categoryview models which would represent the checkboxes.
Now the tricky part that i need some help with is how do I allow user to dynamically add new categories (if he needs to) on the same page. So how would i add new values into the list of categories on view.
Only thing that comes to my mind is to create an ajax post that would call a method that would create the new category in the database. Then i could append a new checkbox representing that category, But then i do not know how i would send that category in the list of categories in viewmodel without refreshing current page. Is this even possible?
If any1 has any ideas how to start on this I would be grateful.

Printing a separate report webpage without displaying in ASP.NET

This is somewhat related to my previous printing question re: remote printing, which I resolved with help here at work. This new situation likely has a simple answer as well, but I have yet to discover it.
To simplify, I have two webpages written in ASP.NET with C# codebehind, which we can call page1.aspx and page2.aspx.
The first page, page1.aspx, is a simple search tool that opens a database and returns a list of reports matching the search criteria into a gridview. The second page, page2.aspx, displays a report in the web browser, given the report ID as a query variable (which I have working). This page is also pre-formatted to be printer friendly.
On page1.aspx, in my gridview, I have two buttons for each row labeled "View" and "Print". The "View" button will retrieve the appropriate order number for the corresponding row, and page2.aspx will load the report based on the order number (again passed as a query variable).
For the "Print" button, however, I would like to print. That is, when the user clicks the button, instead of the page loading onto the screen, I would like for the Print dialog to pop up and allow the user to print the report directly to the printer (since they are able to view the report using the separate button if they should so desire).
I would load page2 into an iframe, probably separately and have the page call a JavaScript print when loaded, or call focus on the iframe and then print on the same object.
You could load the page with a new call, or just load it when page1 loads in the background.
You would, of course, make the iframe hidden from view.

How to bring up new window for each selection from checkbox list in ASP.NET?

I'm new, building a practice project in C# and ASP.NET. Have a checkbox list with 7 insurance products; when a user selects a product, I need to bring up a new window where they can customize this product. What is the simplest way to do this?
To open a new window, you need client-side javascript (window.open).
EDIT
in response to the submit of the list, generate some script statements (see RegisterStartupScript).
But are you really sure that this is what you want: open a handful of new windows?
A different approach would be to remember that list server-side (in Session) and handle those products one-by-one.
EDIT
You could have a redirect page: as long as there are items in the list, take&remove the first one and show the page for that. When that page is finished, redirect back yo the redirect page. When the list is done, go back to the list (or whatever).

Designing a grid website, with navigation in details pages

Need help with technical-designing of a website.
I have a main page with a multi-paged grid.
Whenever you press on a row, you navigate to an extended details page about this row.
Here comes my question, I want to be able inside the details page to add "Next" and "Prev" buttons according to the original grid. (Mind you, the grid can be filtered and ordered in various ways).
How would you approach this scenario?
Update:
We can not work with Session variables since there are scenarios where user moves from a grid, to a details page and then to another grid, and so on...
So saving last dataSet in a session varible will be useless.
You need to create some state to manage your UI workflow. When you display the grid, it is bound to some collection of data. That collection is likely sorted and filtered. Since you will need to reference that data set as part of a larger workflow, you need to either keep the whole (sorted and filtered) collection around (if it is small enough), or keep the criteria that will let you re-query for it (if it is large) in your users session. When you select a row and redirect to the detail page, pass in the selected record in the query string.
Combining the current record from the query string, and the data or criteria stored in the session, you should be able to retrieve the "next" or "previous" record in tandem with what the original data grid displayed. If the user selects Next or Previous, the only requirement would be redirecting to the same page with a different value in the query string for the current record. Since the rest of the criteria or data is in the session, paging through detail pages should be trivial.

Categories

Resources