In the SalesLogix web client it may be necessary to perform some kind of server side code, like data validation, and then based upon what is returned perform some kind of client side action like a confirmation dialog, or opening a new browser window.
The nature of ASP.Net web sites is that client side actions run before server side actions so how can we accomplish performing server validations before running client side code? Well lets take a look.
Suppose we have a button on a opportunity quick form, called “myButton” and when we click it we want to do some data validations and then throw up a client side prompt. lets take a look at what we can do:
On the server on click event of the button we can add something like this (in-line c# code snippet):
Sage.Entity.Interfaces.IOpportunity opp = this.BindingSource.Current as Sage.Entity.Interfaces.IOpportunity; string clientScript = string.Empty; if (opp.SalesPotential<1000) clientScript = "alert(Why don't you sell more?);"; else clientScript = "alert(Good Job!);"; ScriptManager.RegisterStartupScript(Page, GetType(), "UniqueInjectedScriptName", clientScript, true);
As a followup to this post, check out this great idea here:
This makes it much more generic and makes this functionality available from anywhere, not just a specific action.