Page Refresh on popup close and losing page data - sharepoint

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();
}
}

Related

Prevent loading popup in mobile

I have override the CustomerID's Field Updated event in Sales Order page that displays a popup with the custom field UsrCustomerNote for update purpose. It is working fine on web. But, the thing is I want to prevent popup in acumatica mobile app. How do I do this? Here is the code that loads the popup.
BAccountEnq bAccountEnq = PXGraph.CreateInstance<BAccountEnq>();
BAccount bAccount = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.Select(bAccountEnq, row.CustomerID);
var customerNote = (string)bAccount.GetExtension<PX.Objects.CR.BAccountExt>().UsrCustomerNote;
if (!string.IsNullOrEmpty(customerNote))
{
if (CustomerSelector.AskExt(
delegate
{
CustomerSelector.Current.GetExtension<PX.Objects.CR.BAccountExt>().UsrCustomerNote = customerNote;
CustomerSelector.Cache.Update(CustomerSelector.Current);
}) == WebDialogResult.OK)
{
IsOKToUpdate = true;
}
}
Here is how it looks on web:
And, here is the error that is caused by popup.
I want this customization on web but not on mobile keeping the Base method for Field Updated event. I mean like not completely disabling the event but only preventing popup to load if it's in mobile.
Thanks!
In your graph extension, check for the flag Base.IsMobile. You could use that to branch your logic

Return to Previous Url 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});

Add Nav buttons on left hand side of Navigation bar

I have a Xamarin page with a Navigation bar at the top.
I keep changing the views on the page with some button clicks, but the page remains the same.
What I need is, when I load a new view (say View A) on this page, I want to add a Back button on the top Nav bar of the page.
I saw some forums where they are using Custom page renderers to add Back button.
But here, the page remains the same. Only the view changes. So, I guess I need to use the custom view renderer to add the Navigation button.
How can I achieve this, as NavigationController which I need to add a Nav button is present in Page renderers, not View renderers.
I need some help.
Thanks
UIBarButtonItem customButton = new UIBarButtonItem(
UIImage.FromFile("Image/image.png"),
UIBarButtonItemStyle.Plain,
(sender, e) =>{
//InitView
});
NavigationItem.LeftBarButtonItem = customButton;
this.NavigationItem.LeftBarButtonItem.TintColor = UIColor.Orange;

JSF How to display the Navigation confirm popup before forwarding to other page

I'm using Primfaces Layout component in my pages and I'm not using Redirection in navigation when user clicks on the Menu links.
i.e.,I'm NOT using faces-redirect?true and URL doesn't change when user navigates.
I want to display a Confirmation Dialog before user navigates away from current view, like
“Are you sure you want to navigate away from this page?”
So once user clicks on the OK then it should forward to other page or else it should stay in same page if user clicks on CANCEL.
One more constraint is I want this functionality for only few selected pages not all of them.
What is the best approach to deal with this problem?
Primefaces Version: 3.5
JSF Version: 2.1.13
All my ManagedBeans are in #ViewScoped
If you want to try solving this problem from javascript-side, either go with
window.onbeforeunload = function(e) {
return 'Dialog text here.';
};
and see the dialog independent from the link being clicked (see https://stackoverflow.com/a/12132076/1269441). or try adding
onclick="if (!confirm('Your dialog-text here')) {return false;}"
to a selection of links you would like to have the dialog shown.

Custom action after sending Infopath form

I'm using a browser-enabled Infopath form with Sharepoint 2010 and I want to show a modal popup or even redirect to another page after clicking on Submit, saying "Thank you... Your form has been sent...".
I can't use a View (and change to that view on submit) because the form is inside a 'tab' in the page. I mean, the page contains 5 DIVs acessible through 5 buttons.
The DIV which is open by default is the 1st one. The form is inside the 5th DIV.
After the submit action (postback) the page reloads and the 1st DIV is shown, so the user can't see the View with "Thank you...."
Any ideias on how to solve this?
Thanks in advance!
EDIT 2
I tried Andreas' solution but didn't work.
This is my "submit" button code.
public void CTRL114_5_Clicked(object sender, ClickedEventArgs e)
{
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
this.Submit();
HttpContext.Current.Response.Redirect("ThankYou.aspx");
});
} catch (Exception ex)
{
System.Console.Write(ex.toString());
}
}
When I click on Submit, nothing happens. No page redirection, no view switching, no data submitting.
Any ideas?
Thank you!
Popup's do not work with browser-enabled forms, your only possibility will be custom code. In your submit code, you can do a redirect to a static thank you page.
HttpContext.Current.Response.Redirect("ThankYou.aspx");
Edit: In your VSTA Editor, make sure you have System.Web referenced. Without an actual exception it's really hard to say what's not working. Try the following code and post the output please -
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
this.Submit();
HttpContext.Current.Response.Redirect("ThankYou.aspx");
});
}
catch(Exception ex)
{
//implement your logging logic here
}
Edit 2: Can you open the form in preview mode and debug the code? Also consider changing your logging code to something like this:
catch(Exception ex)
{
using(var writer = new StreamWriter(#"C:\log.txt",true))
writer.WriteLine("{0}\t{1}", DateTime.Now, ex.Message);
}
because Console.WriteLine does not work with InfoPath and you never get hold of the actual exception. I'm afraid without a error messsage it will be quite hard to troubleshoot your issue any further.
Another way of redirecting is using the 'Source' parameter of the query string. It is, however, only possible to redirect to pages in the same site collection as the form. E.g.
http://[site]/_layouts/FormServer.aspx?XsnLocation=/sites/[site]/formservertemplates/[form].xsn<b>&Source=/sites/[site]/pages/[page]</b>
If ThankYou.aspx is outside the current site colleciton, you can redirect to a intermediary page which redirects to ThankYou.aspx. I have heard of no other way to bypass this.

Resources