Export to Web Form Button

O

Oblivion

Greetings-

I'm attempting to create a button in a form that, when clicked, will
export the current view in MHT format to a single set location with the
filename set to the contents of one of the form fields; IE if field1 =
"Test Tester" the file would be saved in the hard-coded unchanging
location witht he filename "Test Tester.MHT" This being beyond my
current jscript knowledge, I decided to see if I could get the button
to do a simple export using the example script given in the Help menu
before I tried to do anything more complicated.

However, I cannot even accomplish a simple test export command from a
button using the XDocument.View.Export("C:\\MyView", "MHT"); command.
No error is returned when clicking the button, but nothing happens
either. No file is created.

The button code:

function CTRL10_5::OnClick(eventObj)
{
XDocument.View.Export("C:\\MyView.mht", "MHT");
}

The form is signed and considered fully-trusted by the computer which
I'm attempting to create the MHT file on.

Any and all help is greatly appreciated. Thank you.
 
B

Ben Walters

Hey Oblivion,
This sounds very strange indeed, if your code didn't have the expected
security access I would expect an error to be displayed. However as you
stated you aren't recieving any error. Here are a couple of things to try
1: add some debug code to your jscript e.g. perhaps try showing a message
box after the export XDocument.UI.Alert ("Hello World"); . This way you can
determine if the export is actually hapening.
2: Try signing the form template with a localy generated certificate then
publish the template and test again (I know you said you set the security
but this may help)
3: Try moving your code from jscript to C# if available this way you can
debug your code to see what's actually happening.

Hope this helps

Cheers
Ben
 
O

Oblivion

I figured out what was happening. PEBKAC, to be precise.

Basically, the button ID was different than the function that I was
editing for the OnClick event. I changed the button ID to match the ID
that the function was calling and it worked.

Now if I could just figure out how to set the name of the .mht file
saved to be equal to the contents of one of the fields on the form...

Thanks for your assistance, Ben, I appreciate it.
 
B

Ben Walters

Hey Oblivion,
Good to hear you got the first issue sorted out
as for setting the file name that should be relativley easy simply pass in
the name from the field you want

string FileName =
e.XDocument.DOM.selectSingleNode("my:Fields/my:FileName").text;

e.XDocument.View.Export(@"C:\" + FileName + ".MHT", "MHT");

Hope this helps

Cheers
Ben
 
O

Oblivion

Ben-

I actually managed to get something similar on my own:

var saveField =
XDocument.DOM.selectSingleNode("/my:myFields/my:field1");
var name = saveField.text;

A little less elegant than your solution, but at least I'm starting to
figure this out!

Thanks again for all your help, I greatly appreciate it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top