Return to Previous Url MVC 5 - asp.net-mvc-5

I started learning MVC and i am stuck in this problem.
I have an Order Details page in which I have a button "Edit". When the user clicks on it, opens up a Bootstrap Modal, which i called from a Partial View.
Now Modal opens up and shows the data, loaded from database and saves the data to database.
Everything is working just fine.
I just want the user to go back to that Specific Detail Page from where He/She clicked "Edit" Button.
For example
Detail Page URL is
../orders/details/2
form saves at
..order_detail/edit/[id]
after form submit it should go back to
../orders/details/2
How can i achieve this?
Any help would be much appreciated

Instead of returning on your current View after executing post method you can redirect to the action you want, passing the id. For example:
public ActionResult Edit(int id) {
...
return RedirectToAction("YourDetailsActionHere", new { id = id});
}
And if your action is in different controller you have to pass the controller name as well
return RedirectToAction("YourDetailsActionHere", "YourOtherController", new { id = id});

Related

Controlling the Back Button after Navigation Punchout

I have been trying to control the back button behavior on how far back it goes to the capsule after leaving the navigation punchout command. Such as, after pressing the back button on the website that was punchout, it takes me back two layout screens, rather than one.
The model of my capsule goes in this flow:
(Vocal input) -> Object List (After vocal input) -> Object Page (After selecting an object) -> Website Link Punchout (After an on-click event of the object page)
Website Link Punchout:
result-view {
match : ObjectWebsite (this) {
min(Required) max (One)
}
render {
}
app-launch {
payload-uri("object website link")
}
}
The expected result, while being on the website page, is to return to the object page, not to the object list page.
The output results in returning to the object list page after I press back button to exit the website link.
Thank you for raising this question. The scenario you have mentioned would be a bug, pending verification on our end. Please open a ticket with Developer Support to be notified when this bug is fixed/closed.

Chrome extension keeps resetting

I'm new to chrome extension development but I'm running into issues debugging and with the extension itself. I currently have a form with a submit button and after the user hits submit I change the html to show the data that was just submitted.
document.addEventListener('DOMContentLoaded', function() {
console.log("1");
document.getElementById("submitButton").addEventListener('click', myFunction);
console.log("2");
//getCurrentTabUrl(function(url) {
// renderStatus(url);
//});
});
function myFunction() {
document.getElementById("formOutput").innerHTML = document.getElementById("formInput").value;
alert("hi");
console.log("test");
);
}
In this, 1 and 2 are displayed to the extension debugging console and the alert runs as well when the button is clicked. The test shows up very briefly and then it disappears.The formoutput value changes very briefly as well and then changes back to the default value I have. Does anyone know why my code/the chrome extension would be doing this?
Thanks!
When button with type submit (This is the default if the attribute is not specified) is clicked, the form data will be sent to server and page will be redirected to new page. Then your content script will be injected again, that's why the it changes back to default value.
To avoid this, you could change button with other types, or calling e.preventDefault to prevent default behavior. Then you would want to use Ajax to send data to server, which ensure the whole page won't be redirected and only parts of UI can be updated.

Netsuite: How to insert an iframe on post call

I have written a suitelet which has two parts - GET and POST.
In GET method I have a dropdown and a submit button.
In POST method, I have 5 text fields which display the data based on value fetched from dropdown in GET.
I want to call an iframe on submit button click. iframe will show POST method logic. In short, I don't want to navigate to new page on submit, but to make the whole thing work on a single page.
MY CODE
function init(request, response)
{
if(request.getMethod() == 'GET')
{
//... some code for dropdown and submit
//code for iframe
var context = nlapiGetContext();
var url = 'https://**url-of-post-method-results**.com';
var title = context.getSetting('SCRIPT', 'custscript_suitelet_title')
var content = '<iframe width=960px height=100% style="height:640px;" src=' + url + '></iframe>'
var newField = form.addField ('content', 'inlinehtml', title);
form.addField('extra', 'inlinehtml', '')
form.setTitle (title);
newField.setLayoutType('outsidebelow');
newField.setDefaultValue (content);
form.addSubmitButton('Submit');
response.writePage(form);
}
}
I referred to Marty Zigman's tutorial on embedding iframe. But I'. confused where to embed the iframe, in GET or POST?
To the best of my knowledge, NetSuite has no built in way via their API to avoid a page refresh in a case like this. Clicking the submit button, will by default, submit the form via a post method synchronously. You need to interrupt the click() event method via jQuery on NetSuite's default form submit button using client side code. You would then send the post yourself using jQuery, and on a response, show the information you would like, again via jQuery, by updating the iframe src url.
I apologize I do not have currently have access to an account to be able to give you the appropriate JavaScript. I would be cautious of breakage though since you will need to hack into the NetSuite UI a bit to make this work.

Page Refresh on popup close and losing page data

I have a repeater as user control and other fields in my SharePoint site page. I need to add records to repeater with help of modal dialog. Whatever has been selected in the popup should come to repeater. Whenever I close the popup, I am able to refresh the page, but the page is losing the other fields' data and repeater too.
Am I doing something wrong?
Finally I managed this issue with dopostback using the below snippet.
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}

UITabBarController tab to act as a Logout button instead of showing the corresponding view

I have a UITabBarController based iphone application. I added a new tab called Log Out via the Interface Builder.
However I don't need its corresponding view. I want the Log Out tab to redirect to the Login view as soon as it is clicked (of course some session clearing code is executed as well).
The nearest I've got so far is to redirect from the Log Out View using the viewWillAppear. The result is the same but it doesnt look great because it goes into a blank screen for a couple of seconds and then it redirect to the login screen.
Any help would be appreciated.
You can use UITabbarDelegate methods to accomplish this
Use following delegate method to check for logout buttons index and if found then perform your tasks
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
if (tabBarController.selectedIndex == 4)
{
// perform logout tasks
}
}

Resources