
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);
By utilizing the RegisterStartupScript we add a hook into the page load that will run after the post back from the server validation runs. The result will be a client side action running after you have done some server side action. In this simple example we are simply running a javascript alert function which will display a specific alert based on what the current opportunity’s sales potential is.
As a followup to this post, check out this great idea here:
http://madskristensen.net/post/JavaScript-AlertShow%28e2809dmessagee2809d%29-from-ASPNET-code-behind.aspx
This makes it much more generic and makes this functionality available from anywhere, not just a specific action.
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!