Looking at the USCIS form N-400, you can see that in Part 9 has two buttons, Add Children and Go to continuation page Looking at the XML/JS backing those buttons you get this node for the corresponding field:
<event activity="click" name="event__click">
<script contentType="application/x-javascript">
_KidsContPage.addInstance(1);
xfa.form.recalculate(1);
xfa.host.pageDown( );
</script>
</event>
This is used to add the automatically hidden page to the form in case the user has more than 8 children. My question is using iTextSharp, or perhaps some other method, how do I create this new instance of the page? If you notice you can make multiple copies of this additional children page, if, somehow, you happen to have more than 25 kids, so not getting side-tracked by the unlikelihood of that possibility, I need to know how to create multiples of such a page...
This is what I have so far:
PdfAction cloneAction = PdfAction
.JavaScript(ClonePage("KidsContPage"), stamper.Writer);
stamper.Writer.AddJavaScript(cloneAction);
I've also tried with SetOpenAction
stamper.Writer.SetOpenAction(cloneAction);
private string ClonePage(string formName)
{
return #"
if (xfa.host.name != 'XFAPresentationAgent') {
$._" + formName + #".addInstance(1);
if (xfa.host.version < 8) {
xfa.form.recalculate(1);
}
}";
}
I know that my ClonePage() code is being run, because I see the alert when I tested it earlier, the problem is in the javascript or perhaps I somehow need to run it at server or who knows what I need to do. I opened the XFA PDF in LiveCycle and that's the JS that it's putting out for it, I must be missing something small somewhere...and it works fine in LiveCycle. Please help.
Related
I have a C# WPF application (.NET 4.6) that needs to print a number of Page objects.
Each Page is setup in the XAML editor to be exactly 1 page of A4 in size and the content is build from a number of label, border and image components placed on the Page.
I added a method to my Page class that adds some dynamic data at run-time to the Page and then prints it using PrintVisual().
In fact: Its a loop that fills a Page object with the dynamic content and then calls PrintVisual() to print it. For each iteration, some new content is placed in the Page. (See sample code.)
// Print method of the Page object.
public void PrintIt(int totalpages)
{
PrintDialog pDialog = new PrintDialog();
// If not cancelled then print
if (pDialog.ShowDialog() == false) return; // User cancelled. Don't bother
for(int pagenum=1; i<=totalpages; i++)
{
// Omitted several dozen statements that fill/update the content of various
// label components based on the pagenumber.
this.UpdateLayout(); // Required to re-render new page properly before printing.
pDialog.PrintVisual(this, "My PrintJob");
}
}
This works well, expect for the fact that each PrintVisual() creates a separate print-job, which makes it impossible to print double-sided (and when printing to PDF each page ends up in a new file).
I need to tie all pages (PrintVisual() calls) in a single print-job. I'm fairly sure that I need to use a PrintDocument(), but I can't seem to figure out how to construct the required FlowDocument and populate it with my actual prints.
I'm quite new to WPF programming so I'm probably missing something obvious, but as far as I can't tell there isn't any simple way to do this.
Can anyone give me a push in the right direction ?
My company doesn't allow me to show the code so I will describe it the best I can.
I have an HTML page containing 4 frames.
One on top containing the title and some other and the user's name
One one the bottom containing the version and other pieces of information
One on the left containing the menu
The last one is on the right and contains the content of the website.
Each frame contains an .aspx page. The page of the left frame doesn't change, and the one on the write is almost always changing. The 2 others don't matter.
I've been asked to add shortcuts leading to differents places. Those shorcuts will involve F keys. For instance, F1 will open the PDF help file in a new tab, F2 will lead to a certain page, etc...
I am using IE8 and I can't update it. And I know that some F keys are already used by it but I found a way to disable the functions called by them so that I can use them for my own shortcuts.
I tried to add the shortcuts in Javascript with a function which checks if a F key is pressed and released. I have successfully added this function in my left frame which always contains the same .aspx page, but as soon as I click on the right frame, it seems that I lose the focus on the other one and the shortcut doesn't work anymore. My problem is that in the right frame, about a hundred different .aspx can be called, so I can't add the Javascript function in each one. Moreover, I do not have access to the HTML page containing the frames, so I can not add the code here neither.
The best for me would be to be able to have the shorcut function in my left frame and that it is called even if the focus is on my right panel.
Do you know if a such thing is possible ? Or do you have any idea of any other way to solve this issue ?
Thanks.
(And forgive me for my bad grammar, english is not my native language)
You will need the functionality (ie JavaScript) repeated in every frame where you need it.
What you can do is create a base page and then inherit your ASPX pages from that, for instance:
public class PageWithShortcuts : System.Web.UI.Page
{
// Add JavaScript-outputting functions and other shared functionality here
private void Page_Load(object sender, System.EventArgs e)
{
RegisterStartupScript("mycode", "<script>...</script>");
}
}
Your pages then all inherit from this:
public class CheckoutPage : PageWithShortcuts
{
...
}
Is there a way to refresh associated Grid View ?
I have a Sales Order View on the Account Form, on this Form I have a button (New Order) that open a new Sales Order Form, in this form I do my Orders,
The question is : When I save on my Order Form I want to refresh my Order associated View (in the Account Form) , but I don't know how to get the control name or how to access to it.
I tried many ways Like
Xrm.Page.ui.controls.get("Orders").refresh();
document.getElementById("areaOrders").contentWindow.location.reload(true);
Thank's.
To refresh a subgrid you can use
Xrm.Page.getControl('new_subgrid').refresh();
However in my experience it is very buggy (since RU12 anyway), so use with caution. You also need to check the type of the control you retrieve and ensure it is a grid or an error will be thrown.
However you have asked a slightly different question:
When I save on my Order Form I want to refresh my Order associated View (in the Account Form)
Which I understand to mean you have an Order form opened from an Account form and want to refresh the subgrid on the Account form.
The easy answer is no, you cannot do this in a supported way.
It may be possible but it wouldn't pretty. You'd need to get a reference to the opening window, which may be available in
window.opener
I haven't tried and am not infront of a machine to try it. But I would advise against it, the alternative is a single click to manually refresh the subgrid; it isn't a bad alternative.
This is a javascript function I wrote to force Subgrid loading if the form contained more than 4 subgrids. I believe a recent rollup has made the purpose of the code obsolete, but it might be helpful for you to find your subgrids:
/*
By default, CRM only loads the first 4 subgrids on a form. This will load
up all subgrids on the form, or only the number (over the default 4) if specified
*/
forceSubgridLoad: function (countOver4) {
$(document).ready(function () {
var links = $("a.ms-crm-List-LoadOnDemand");
for (i = 0; i < links.length && (countOver4 == null || i < countOver4); i++) {
links[i].click();
}
});
},
I have blogged about auto-refreshing a sub-grid in Microsoft Dynamics CRM.
The solution is an unsupported customization, and basically boils down to this:
document.getElementById("crmGrid").control.refresh();
Replacing "crmGrid" with the div id of the sub-grid that is to be refreshed.
As far as I know there is no supported way to do a refresh.
I'm creating a WP7 application using C#, and I require to pass data from one page to the other.
I found solutions on SO, but I'm still running into problems.
On 'Page 1', I wish to display a list, that can be populated by the user, using input from 'Page 2'.
I used the following statement in 'Page 2' while navigating back to 'Page 1': NavigationService.Navigate(new Uri("/MainPage.xaml?text="+WhoBox.Text, UriKind.Relative));
WhoBox is a Text Box.
On 'Page 1', I have the following:
protected override void OnNavigateTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (NavigationContext.QueryString.ContainsKey("text"))
ListBlock.Text = ListBlock.Text + NavigationContext.QueryString["text"];
}
Now, this works, but in a limited fashion. If I try adding something from 'Page 2' for a second time, it replaces what is present in ListBlock (which is a Text Block) with the newly added text instead of appending it.
Shouldn't ListBlock.Text = ListBlock.Text + NavigationContext.QueryString["text"]; cause the new text to be appended, rather than to entirely replace the older text?
EDIT: I may have found the solution. For whatever reason, no changes in the XAML or .cs file are reflected when I run the program using F5. Am I doing something wrong? For example, even if I delete a button, it still appears when I Debug (F5) the program. Is there some setting I need to change? Or am I supposed to use some other command? I'm relatively new to Visual Studio, so please excuse me.
The problem is that the moment you again leave your page 1 it is basically disposed of. Meaning any text that was set in the Listbox is also removed. You will , in other words, need to save the state of that page before leaving it.
There several possibilites here:
Use AppSettings (see Windows phone 7 config / appSettings? )
Write the state to a local database
Do a quick'n dirty fix by saving the Text in the App.xaml.cs which all pages can work with: First you need to create the application-wide variable (and initialize if needed) inside the app.xaml.cs file. For example:
public partial class App : Application
{ public string myText;
From now on you can reach any App-variable through the Application.Current object. So if you need to access bigVar from some page in you application (e.g. MainPage) you simply type:
string Text = (Application.Current as App).myText;
Consider using sessions and datatable: Storing and retrieving datatable from session
I'm serving up PDFs from a SQL db and presenting them in the browser. I'm trying to figure out a way to embed a number in the PDF dynamically so that the recordID for that PDFs SQL record is available to me when the user submits the XML form data. The user hits the submit button on the form and the form submits its XML data to my submission page. If there is some way of changing the submission URL on the fly then I could do a query string to pass my self the recordID. I'm not generating the PDF in code, its being created by hand and then uploaded to my site.
Edit
User is given a link someServer.com/pdfLink.aspx?formID=5 they go there and that pages pulls a PDF from the DB and displays it. This pulls up acrobat in browser full size so my aspx page isn't in control of submitting the completed form, Acrobat is. The user fills out the form and hits the submit button in the form. This submit button was set up at form design time to point to another page someSite.com/pdfSubmit.aspx The submit button posts the XML data to that page and I can process it. I need the recordID in the query string for the someSite.com/pdfSubmit.aspx page. To do this I would need to modify the PDF to either add the recordID and query string to the submit button's submit URL, or embed it in the PDF else ware. The big question is how do I modify the PDF just before I display it via someServer.com/pdfLink.aspx?formID=5 to do either of these two options.
Embedding a number in PDF is not exactly kosher, but there are some things that you can do that will honor the spec.
The current PDF spec says that "The last line of the file shall contain only the end-of-file marker
%%EOF
but there is some wiggle room - the implementation details say that it doesn't technically have to be the last line of the file, but only has to appear in the last 1K and, generally speaking, if you don't muck with things too much, most compliant readers won't even blink. If I had to do this, I would be inclined to add a newline (if there isn't one), then a % (which is a PDF comment), a marker to let me know it's mine, and finally the number. So something like:
// assume we already know it ends with %%EOF
void AppendNumberToPdf(Stream stm, int number, bool addNewline)
{
stm.Seek(0, SeekOrigin.End); // go to EOF
StreamWriter writer = new StreamWriter(stm, new ASCIIEncoding(), 1024);
writer.WriteLine(string.Format("{0}% {1} {2}", (addNewLine ? "\n" : ""), kMyMarkerString, number));
writer.Flush();
}
kMyMarkerString should be something like "MyApplicationDocumentIdentifier:" or some such thing that will make it easy to identify your tracks.
The querystring is read-only so you cannot dynamically change it at runtime. However can you:
Add the recordID to the form at the time the submit page is initially rendered
Can you process the submit form and then do a Response.Redirect or Server.Transfer to the correct page with the recordid parameter added to the querystring
While trying #plinth's suggestion I realized I had to change from XML submission (since his data was on the PDF directly. So I changed the form to submit as XDP which has XML data + embedded PDF. When I did this and viewed the raw XDP that the form submitted I ran across this.
<?xml version="1.0" encoding="UTF-8" ?>
<?xfa generator="XFA2_4" APIVersion="3.0.8262.0"?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2010-05-04T15:15:00Z" uuid="6d0944c8-1573-442c-9c85-11e372bd38c3">
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<xfa:data>
<form1>
<TextField1>TestMe</TextField1>
</form1>
</xfa:data>
</xfa:datasets>
<pdf href="ViewPDF.aspx?formID=10" xmlns="http://ns.adobe.com/xdp/pdf/" />
</xdp:xdp>
Notice the 2nd to last line. It automatically includes the PDF's url which had the formID value that I needed. So all I had to do was get the XDP instead of pure XML post from the form and it gives me everything I needed.