Trying to Prompt User with XDocument.UI.Confirm

C

Chrisf

I created an InfoPath 2008 form that has a Delete button. In the code behind
I would like to prompt the user to verify that it's okay to delete. After
researching online I thought this statement would do it.

string response = XDocument.UI.Confirm("Okay to Delete? ", 4);

But I am getting an error that says "The name 'XDocument' does not exist in
the current context"

Does anyone know what I am missing or if there is something else I should
use to prompt for a Yes/No type answer?

Thank you in advance for your help.
 
C

Chrisf

Thank you for your response. I was able to add the
Microsoft.Office.Interop.InfoPath.SemiTrust name space as you suggested, but
I am having trouble figuring out the correct syntax for the confirm prompt.
The Delete button is included in a repeating table using InfoPath 2007.


I originally tried:

string response = XDocument.UI.Confirm("Okay to Delete? ", 4);

But am getting this error:

The best overloaded method match for
'Microsoft.Office.Interop.InfoPath.SemiTrust.UI2.Confirm(string,
Microsoft.Office.Interop.InfoPath.SemiTrust.XdConfirmButtons)' has some
invalid arguments


This is my most recent attemp:

deleteChoice = Microsoft.Office.Interop.InfoPath.SemiTrust.UI2.Confirm("Do
you want to Delete?", XdConfirmButtons.xdYesNo);


That gives me this error:

An object reference is required for the nonstatic field, method, or property
'Microsoft.Office.Interop.InfoPath.SemiTrust.UI2.Confirm(string,
Microsoft.Office.Interop.InfoPath.SemiTrust.XdConfirmButtons)'

THis is the latest version of the code for the clicked event

public void CTRL20_7_Clicked(object sender, ClickedEventArgs e)
{
XdConfirmChoice deleteChoice;
// Retrieve the name of the program from the current row
string prog =
e.Source.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:CAPS/Prog", NamespaceManager).Value;
// string response = XDocument.UI.Confirm("Okay to Delete? ", 4)
//string response =
Microsoft.Office.Interop.InfoPath.SemiTrust.UI2.Confirm("Okay to Delete?",
XdConfirmButtons.xdYesNo);
deleteChoice =
Microsoft.Office.Interop.InfoPath.SemiTrust.UI2.Confirm("Do you want to
Delete?", XdConfirmButtons.xdYesNo);
}
 
N

Nebelstreif

It forks for me in the form

switch (thisXDocument.UI.Confirm("Would you like some pizza?",
XdConfirmButtons.xdYesNo))
{
case XdConfirmButtons.xdYes :
...
break;
case XdConfirmButtons.xdNo :
default :
break;
}
 

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