Asp.net MVC 3 partial view postback - asp.net-mvc-2

I am new to mvc and I have a question
I have a page (asp.net Mvc 3) called profile which contains 3 partial view called (1) Address,Qualification,Experience.
Each of the partial view should allow you to add its details and save it details/contents without affecting the others.
How can I attach an action to each partial view save button and postback the result without refreshing other partial view.
Can someone explain this to me with and without using jquery/ajax

without ajax or jquery you'd be stuck with doing something horrible like iFrames... Stick to jquery, it is the best and easiest way.
Actually, here is one way you might be able to do it.
Name the "Submit" buttons according to the method you want called. Then, have all of your 3 sets of data inputs within one <form></form> which posts to an intermediate Controller endpoint.
In the intermediate controller endpoint, determine which button was pressed, then pass the correct data to your normal control methods, and push all the other data back to the view. That way you can fill out all the inputs, click the appropriate submit button, then only the correct data gets used! Then all the other data gets pushed back to the view and the approprate input boxes get filled out.

Related

How much should presenters know about the view?

I have a Flutter mobile application where I do request data from the backend, and each individual record of this data have it's own identifier and category. For each of these identifiers I want to display them properly and also redirect the user to the correct page of the app. An example:
User enter the page, and we request the data
Data arrives and we present it.
When clicking at each item, we should redirect the user to the appropriate page of that item.
Question 1) Where should the route definition be?
Currently I created a Widget and made a switch case on the identifiers to define the route of each one click.
But shouldn't this be done already in the presenter, so the view would only display it and create the callbacks to redirect it with the given route? My concern about it is that then the presenter would know too much about the View, or am I wrong?
Question 2) Each of those items that I mentioned have their priority, and in the view each priority is displayed in their own way, like Urgent priority is displayed in red and so on...
Should presenter also define these colors for the view? The problem is that this Color it's an object from the Flutter Framework which I would like to avoid in this layer...
My current implementation is like this:
View calls controller (bloc) which call usecase that responds with the needed data.
Presenter (same bloc) gets this data and format the correct title for each identifier
The view gets the view model from presenter and displays it, but also need to do a switch case on the identifier of each item to know about the color of the item on the screen and also the route to be redirected when clicked.
Any help is appreciated.

two view in the same page

I am working with asp.net MVC2, I'm new in development. net
I have a view that contains 2 dropdownlist and a button, I want when I click the button, another view is displayed, I want both to appear on the same page
There is two way you can implement this
1) With Complete post back you can use Html.RenderAction or load the partial view. You can use some flag to differentiate between the first time page load and post back
2) You can use the jquery AJAX and call the controller action of another View and get the content and write it to the div of the page .
Please do some research work on both and I think you can get the result as you want.

Navigation in mvvm

I am trying to navigate on a frame with pages but instead of giving views to the page I am giving view models.
This works fine, but the problem is when I navigate between the pages the status of the radio buttons for example doesn't stay the same. It stays only if I use the views and not the view models.
Any ideas?
Thanks.
Some code to explain how you navigate between each control would allow us to give you more specific answers, currently we can only guess what you are doing.
It sounds like you are creating a new instance of each ViewModel when you are navigating between pages. This of course means things such as radio buttons and control states will not remain consistent.
You could use a framework such as MVVM Light and make use of their ViewModelLocator pattern. This means you could have one static instance of each ViewModel.
You could also store all of these states in a simple data model, and then simply have your new ViewModel instance refer to this model and update it's check boxes etc appropriately.

Editing Records with MVVM/MVVM-Light

I have created a very simple wpf app with mvvm light.
I have rows in a list view, these are templated representations of Book objects.
I can click a row, then click an edit button, this button loads a new window and sends the new window the book to edit (using mvvm-light's Messenger).
The issue I have is when I edit the record in my new window the data on the main form is updated. The text boxes are bound to the object received via the Messenger.
I know this is because I have essentially passed a reference to the same Book object around the place, therefore I update in one place.. and voilĂ  it updates on the main page too.
What I would like to know is.. is there a standard way/method/concept to achieve what I am trying to do? i.e. create an "edit" page/screen with the option of discarding the edits?
thanks.
Could you make your entity implement ICloneable and create a clone for editing?

Calling a Composite's GWT method from another Composite

I'm new to GWT and trying to make a simple app (like a small version of fmylife). Up to now i made a composite that loads the facts and another composite that has a form to submit new facts (this one has a load method that clear the list and populate again).
I have a button that when you press it, it shows a Window with a form.
That form is used to add new Facts. But I want to refresh the main page when the Fact is added correctly and close this window.
How should I do this? Should I pass some kind of callback to the Window form?
Edit: I didn't express well enough, Window is a DialogBox provided by smartGWT.
Take a look at Events and the Event Bus.
You can also watch this video for a better explanation.
Sure, why not? Pass a callback with some method like onSave to the composite contained in the DialogBox. Design the flow in such a way that the DialogBox composite is always editing the fact model, and it it not be aware of whether it is creating a new fact model or editing an existing one. Let the DialogBox invoke onSave using the callback, when the user submits the popup.
Keep the fact collection data structure CRUD logic out of the DialogBox composite.
You should use DialogBox or PopupPanel instead of opening a new window (most modern browsers opt to open a new tab either way). That way you won't leave the page (that's the whole point of this AJAX thing, right?), you'll just overlay a new Widget over it and then on "submit" it will hide/destroy itself and add a new fact (without reloading the whole page).
Agreed with the DialogBox and PopupPanel solution above. However, if you'd still like to use Window, the following solution comes to mind.
Extend Window and provide hooks to the values you want back. Then, when you create the new CustomWindow, call the addWindowCloseHandler method to get notified when the CusomWindow is being closed. On that event, get the values you need and allow the window to close. Then make an async call to refresh your main page.