CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> .NET

 How to stop a form from submitting (C#)

Print topic Send  topic

Author Message
AndyGB4

Posts: 122
Posted: 01/17/2013, 8:20 AM

Hey everyone,

I have a record, that when someone inserts (or updates), it runs a certain function, and based the on the result returned, I would like to stop the form from submitting.

For example, if the value returned from the function is 0, then stop submitting the form.
Does anyone know a way to do this?

The function I wrote is being called in the BEFORE INSERT event, by the way.
View profile  Send private message
Lucius

Posts: 220
Posted: 01/17/2013, 4:45 PM

Hi,

Check those 2 topics in CCS help file:

-InsertAllowed Run-Time Property
-UpdateAllowed Run-Time Property

Not sure this is available in .NET though.

If not there is a very easy workaround.
In your Before Insert event change the Insert SQL to for example "Select 1;" if you wish to forbid the insert. This is described in help file under "Custom Insert Type Property" and "Custom Insert Property"
View profile  Send private message
AndyGB4

Posts: 122
Posted: 01/18/2013, 8:01 AM

Oh that's really clever! I'll give that a try.

Thanks!
View profile  Send private message
AndyGB4

Posts: 122
Posted: 01/18/2013, 12:01 PM

So I think the InsertAllowed Run-Time Property is only for PHP and a few other languages, but not C#..

And I tried this line of code in the BeforeInsert event:
((TableCommand)Select).SqlQuery = new StringBuilder("select 1;");
But the form was still inserted.

I'm pretty stumped on this one.
View profile  Send private message
cvboucher

Posts: 191
Posted: 01/18/2013, 11:59 PM

In the InMotion templates (which I know you aren't using but is what I know) there is an OnValidate for each field and for the form. Add one of the Validate actions to one of the OnValidate events. Then right click on the action and select Show Code to see how CodeCharge does validation. With this code you can also provide an error message to the end user.

HTH,
Craig
View profile  Send private message
DataDoIT
Posted: 01/31/2013, 6:58 PM

You'll want to use CmdExecution.

//Tasks_BeforeExecuteUpdate
if(DBUtility.UserId == item.user_id_assign_to.Value)
CmdExecution = false;

//Tasks_BeforeExecuteDelete
if(DBUtility.UserId == item.user_id_assign_to.Value)
CmdExecution = false;

//Tasks_BeforeExecuteInsert
if(DBUtility.UserId == item.user_id_assign_to.Value)
CmdExecution = false;

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.