ReportError in C# (OnValidate-event)

S

StefanO-nl

I posted it as a reply of a previous post, but I guess new posts are more
read...

I want to enable the red dashes around an invalid textbox from C# code.

I know in script it's possible like this:
eventObj.ReportError(eventObj.Site, message, false);
see for more details:
http://msdn.microsoft.com/library/d...y/en-us/odc_ip2003_tr/html/odc_INF_Lab_05.asp

But in C# the ReportError of the DataDOMEvent expects 6 parameters.

And when I try e.Site as the first parameter, an InvalidArgumentException is
thrown with the message:
InfoPath has encountered an error. The operation failed.
The form's code contains an error.
The following call in the form's code failed: DataDOMEvent.ReportError
The parameter is incorrect.

Without saying which parameter, but my guess is the first parameter.
Has anyone got a working example of how to use the ReportError in C#?
And does it enable the red dashes?
 
M

Matthew Blain \(Serriform\)

It's probably not the first parameter. Make sure all the parameters are
present, or use Type.Missing for optional parameters.

Check out the Developer's Reference. On my machine it's at c:\Program
Files\Microsoft Office\OFFICE11\1033\INFREF.CHM. On yours it's probably
somewhere else, 1033 being US-English.

--Matthew Blain
http://tips.serriform.com/
 
S

StefanO-nl

Thanks, you were right. It wasn't the first parameter, it's was the last.
I didn't know what it was, but it was a string, so I thought I could use any
string, but only "modeless" and "modal" are valid values.

Today I downloaded the new InfoPath 2003 Toolkit for Visual Studio .NET,
with all the help I need...

An example of how to use ReportError:

string shortMessage = "Invalid pattern";
string detailedMessage = "You entered an invalid pattern here. The first 6
numbers must be a valid Modulus 11 Check Digit Calculation, the 7th
character must be a B and the last character must be 3, 6 or 9."

e.ReportError(e.Site, shortMessage, false, detailedMessage, 1, "modeless");
 

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