Docusign - Another ways to retrieve file - iframe

Is there another solutions rather than pass the returnUrl parameter. For example, retrieve the file directly in my server.
I have an iframe in a popup with the signature process. When I click on "Completed", the program launch my return url on iframe. But, I don't want that. I would prefer to close the popup and so to detect that the button "Completed" was clicked and the URL changed.
I have this code for detecting location change but got this error : "Origin cross platform".
window.FinishSignatureProcess = function (event, e)
{
try {
var source = e.contentWindow.location.hash; //Line problem
}
catch (e) {
//Exception
}
}

You can use the Docusign GetEnvelopeDocument API to retrieve the bytes of the document

I found a solution for my problem.
I simply redirected to a page indicating that it's finished and it's up to the user to close the popin.

Related

Is it possible to programmatically call a Chrome Custom Tab, but as "incognito mode"?

In some case, a user might not want the chrome custom tab to show up in their browsing history. Is there any way the app could tell the Chrome Custom Tab to display the webpage in incognito mode, and avoid storing that URL in the user normal browsing history?
If that's currently not possible, where could someone submit a feature request for that?
Thanks!
It is possible now. For example in C#:
try
{
string dataFolder = "C:\userFolder"; // If you need to maintain your browser session, you can configure a user data directory
string urlToOpen = "https://shalliknow.com"; // replace your url to open
Process process = new Process();
process.StartInfo.FileName = #"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
process.StartInfo.Arguments = $"--new-window={urlToOpen} --start-maximized --incognito --user-data-dir=\"{ dataFolder}\""; // SSH new Chrome
process.Start();
}
catch (Exception ex)
{
Console.Writeline("Exception while opening link in browser");
}
The source of this code, as well as a list of command line arguments for chrome.exe can be found here:
https://shalliknow.com/articles/en-scs-how-to-open-chrome-in-incognito-mode-programmatically-in-csharp

JavaFX confusing event handling on System Exit

The code bellow generates an Alert Dialog with two buttons, Ok and Cancel; and it also works as expected: if I click Ok, the system exits, otherwise the dialogs vanishes.
The strange thing is: if I ommit the else block handling the event, the platform will always exit, not considering the button I clicked.
Is that really the expected behaviour? Am I missing something?
private void setCloseBehavior()
{
stage.setOnCloseRequest((WindowEvent we) ->
{
Alert a = new Alert(Alert.AlertType.CONFIRMATION);
a.setTitle("Confirmation");
a.setHeaderText("Do you really want to leave?");
a.showAndWait().ifPresent(response -> {
if (response == ButtonType.OK) {
Platform.exit();
} else {
we.consume();
}
});
});
}
Here is the documentation for windows.onCloseRequest:
Called when there is an external request to close this Window. The installed event handler can prevent window closing by consuming the received event.
So, if you don't consume the close request event in the close request handler, the default behavior will occur (the window will be closed).
You don't really need to invoke Platform.exit() in the close request handler because the default behavior is to exit, so you could simplify your logic. You only need to consume the close request event if the user does not confirm that they want to close:
stage.setOnCloseRequest((WindowEvent we) ->
{
Alert a = new Alert(Alert.AlertType.CONFIRMATION);
a.setTitle("Confirmation");
a.setHeaderText("Do you really want to leave?");
Optional<ButtonType> closeResponse = alert.showAndWait();
if (!ButtonType.OK.equals(closeResponse.get())) {
we.consume();
}
});
There is a similar fully executable sample in the answer to the related StackOverflow question:
How can I fire internal close request?.

How to display save confirmation message on my Web form when user saves new form by clicking Save button

I am very new to ASP.NET. I am working on some other developer's Web form. I have been asked to fix a bug which says:
No success message is displayed when user clicks Save button after
adding information to the form (first time or while updating)
There is a Label at the top of the page with ID lblMsgs
<asp:Label ID="lblMsgs" runat="server">
I have added this to the Code behind in the appropriate place:
lblMsgs.Text = "Message Text";
Now, my question is how do I modify the HTML or code behind to make sure that when Save button is clicked, the code checks that the data is saved to the database and displays save successful message on the Web form.
Can you please help by giving example of the code using my label ID above?
Thank you in advance.
That's a pretty vague question, but if your looking for data validation you should look at the built in ASP.NET Validators. This can do client/server side data validation. As for returning a message to the user based on a successful update to the DB, that is going to be solution specific depending on what type of data layer your using.
On your Save button handler, you can add validation logic if whether the data is valid or not.
protected void ValidateSave(object o, EventArgs e){
if (Page.IsValid) {
// Save to DB and notify of update status
var success = SomeDBMethod.Update...
if (success){
DoAlert("Saved Successfully!");
}
}
else { lblMsgs.Text = "Failed"; }
}
// Call client-side alert
private void DoAlert(string message) {
ClientScriptManager cs = Page.ClientScript;
var x = "alertScript";
if (!cs.IsStartupScriptRegistered(cstype, x))
{
String script = string.Format"alert('{0}', message);";
cs.RegisterStartupScript(cstype, x, script, true);
}
}

jQuery UI autocomplete is not displaying results fetched via AJAX

I am trying to use the jQuery UI autocomplete feature in my web application. What I have set up is a page called SearchPreload.aspx. This page checks for a value (term) to come in along with another parameter. The page validates the values that are incoming, and then it pulls some data from the database and prints out a javascript array (ex: ["item1","item2"]) on the page. Code:
protected void Page_Load(object sender, EventArgs e)
{
string curVal;
string type ="";
if (Request.QueryString["term"] != null)
{
curVal = Request.QueryString["term"].ToString();
curVal = curVal.ToLower();
if (Request.QueryString["Type"] != null)
type = Request.QueryString["Type"].ToString();
SwitchType(type,curVal);
}
}
public string PreLoadStrings(List<string> PreLoadValues, string curVal)
{
StringBuilder sb = new StringBuilder();
if (PreLoadValues.Any())
{
sb.Append("[\"");
foreach (string str in PreLoadValues)
{
if (!string.IsNullOrEmpty(str))
{
if (str.ToLower().Contains(curVal))
sb.Append(str).Append("\",\"");
}
}
sb.Append("\"];");
Response.Write(sb.ToString());
return sb.ToString();
}
}
The db part is working fine and printing out the correct data on the screen of the page if I navigate to it via browser.
The jQuery ui autocomplete is written as follows:
$(".searchBox").autocomplete({
source: "SearchPreload.aspx?Type=rbChoice",
minLength: 1
});
Now if my understanding is correct, every time I type in the search box, it should act as a keypress and fire my source to limit the data correct? When I through a debug statement in SearchPreload.aspx code behind, it appears that the page is not being hit at all.
If I wrap the autocomplete function in a .keypress function, then I get into the search preload page but still I do not get any results. I just want to show the results under the search box just like the default functionality example on the jQuery website. What am I doing wrong?
autocomplete will NOT display suggestions if the JSON returned by the server is invalid. So copy the following URL (or the returned JSON data) and paste it on JSONLint. See if your JSON is valid.
http://yourwebsite.com/path/to/Searchpreload.aspx?Type=rbChoice&term=Something
PS: I do not see that you're calling the PreLoadStrings function. I hope this is normal.
A couple of things to check.
Make sure that the path to the page is correct. If you are at http://mysite.com/subfolder/PageWithAutoComplete.aspx, and your searchpreload.aspx page is in another directory such as http://mysite.com/anotherFolder/searchpreload.aspx the url that you are using as the source would be incorrect, it would need to be
source: "/anotherFolder/Searchpreload.aspx?Type=rbChoice"
One other thing that you could try is to make the method that you are calling a page method on the searchpreload.aspx page. Typically when working with javascript, I try to use page methods to handle ajax reqeusts and send back it's data. More on page methods can be found here: http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx
HTH.

How to open new window with streamed document in ASP.NET Web Forms

I have an ASP.NET Web Forms application. I want to have a button to post back to the server that will use my fields on my form (after validation) as parameters to a server process that will generate a document and stream it back to the browser. I want the form to be updated with some status results.
What is the best way to achieve this? Right now, I've got the button click generating the document and streaming it back to the browser (it's a Word document and the dialog pops up, and the Word document can be opened successfully) but the page doesn't get updated.
I have jQuery in my solution, so using js isn't an issue if that is required.
I have a very similar process on one of my servers, and the way I've handled it is to create a temporary document on the server rather than doing a live stream. It requires a bit of housekeeping code to tidy it up, but it does mean that you can return the results of the generation and then do a client-side redirect to the generated document if successful. In my case, I'm using jQuery and AJAX to do the document generation and page update, but the same principle should also apply to a pure WebForms approach.
This was way more difficult to do than I thought. The main issue is with opening a new browser window for a Word document. The window briefly flashes up, then closes - no Word document appears. It seems to be a security issue.
If i click a button on my page, I can stream the Word doc back as the response, and the browser dialog pops up allowing me to Open/Save/Cancel, but of course, my page doesn't refresh.
My final solution to this was to use a client script on the button click to temporarily set the form's target to _blank. This forces the response to the click on the postback to go to a new browser window (which automatically closes after the download dialog is dismissed):
<asp:Button Text="Generate Doc" runat="server" ID="btnGenerateDoc"
onclick="btnGenerateDoc_Click" OnClientClick="SetupPageRefresh()" />
My SetupPageRefresh function is as follows:
function SetupPageRefresh() {
// Force the button to open a new browser window.
form1.target = '_blank';
// Immediately reset the form's target back to this page, and setup a poll
// to the server to wait until the document has been generated.
setTimeout("OnTimeout();", 1);
}
Then my OnTimeout function resets the target for the form, then starts polling a web service to wait until the server process is complete. (I have a counter in my Session that I update once the process has completed.)
function OnTimeout() {
// Reset the form's target back to this page (from _blank).
form1.target = '_self';
// Poll for a change.
Poll();
}
And the Poll function simply uses jQuery's ajax function to poll my web service:
function Poll() {
var currentCount = $("#hidCount").val();
$.ajax({
url: "/WebService1.asmx/CheckCount",
data: JSON.stringify({ currentCount: currentCount }),
success: function (data) {
var changed = data.d;
if (changed) {
// Change recorded, so refresh the page.
window.location = window.location;
}
else {
// No change - check again in 1 second.
setTimeout("Poll();", 1000);
}
}
});
}
So this does a 1 second poll to my web service waiting for the Session's counter to change from the value in the hidden field on the page. This means it doesn't matter how long the server process takes to generate the Word document (and update the database, etc.) the page won't refresh until it's done.
When the web service call comes back with true, the page is refreshed with the window.location = window.location statement.
For completeness, my Web Service looks like this:
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : WebService
{
[WebMethod(EnableSession=true)]
public bool CheckCount(int currentCount)
{
if (Session["Count"] == null)
Session["Count"] = 0;
var count = (int)Session["Count"];
var changed = count != currentCount;
return changed;
}
}
Hopefully that helps somebody else!

Resources