Microsoft KB Archive/270714

= How To Validate Visual InterDev Design-Time Controls with Client and Server Scripting Platforms =

Article ID: 270714

Article Last Modified on 5/2/2006

-

APPLIES TO


 * Microsoft Visual InterDev 6.0 Standard Edition

-



This article was previously published under Q270714



SUMMARY
This article describes how to validate a Visual InterDev Design-Time Control (DTC) with both client-side and server-side DTC scripting platforms.



Server-side DTC
In order to validate a server-side DTC from client-side code, you need to use the thisPage_onbeforeserverevent method. This method allows you to validate your server-side DTCs with regular client-side JavaScript. To do this, perform the following steps:

 Create a new Visual InterDev project, and add a Data Connection. Add an Active Server Pages (ASP) page to the project. Drag a Recordset DTC from the toolbox, and place it in the  section of the new ASP page. If you are prompted to enable the Scripting Object Model, click Yes. Set the following properties for the Recordset:  Set Connection to the name of the Data Connection that you created in step 1. Set Database Object to Tables. Set Object Name to the name of a table in your database.</li></ol> </li> Drag a Textbox DTC from the toolbox, and place it in the <BODY> section of your ASP page after the Recordset DTC. Right-click the Textbox DTC, and select Properties. In the resultant dialog box, set the following properties:

<ol style="list-style-type: lower-alpha;"> Set Recordset to the Recordset DTC that you created in step 3.</li> Set Field to a valid field name in your database.</li></ol>

Click OK.</li> Drag a Button DTC from the toolbox, and place it in the <BODY> section of your ASP page after the Recordset DTC. Right-click the Button DTC, and select Properties. In the resultant dialog box, set the following properties:

<ol style="list-style-type: lower-alpha;"> Set Name to btnUpdate.</li> Set Caption to Update.</li></ol>

Click OK.</li>  Paste the following server-side ASP code in the heading section of your page: <% Sub btnUpdate_onclick Recordset1.updateRecord End Sub %>                   </li>  Paste the following client-side ASP code in the heading section of your page: <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>

</SCRIPT> </li> You can now change and update the value in the textbox. When you click the Update button, the validation script tests if the value is &quot;Test Value.&quot; If it is, the data is updated. Otherwise, a message box warns that the value is not correct, and the update event is cancelled.</li></ol>

Client-side DTC
NOTE: Client-scripted DTCs use Dynamic Hypertext Markup Language (DHTML) and Remote Data Services (RDS), which are not supported in Netscape browsers.

In order to validate a client-side DTC, your validation code must consist only of client-side code. To do this, perform the following steps: <ol> Create a new Visual InterDev project, and add a Data Connection.</li> Add an Active Server Pages (ASP) or HTML page to the project.</li> In the HTML Source editor, make sure that you are on the Source tab. Right-click between the <BODY> and </BODY> tags, and select Properties. In the resultant Properties dialog box, make sure that the DTC scripting platform is set to Client (IE 4.0 DHTML), and then click OK.</li> Drag a Recordset DTC from the toolbox, and place it in the <BODY> section of the new page. If you are prompted to enable the Scripting Object Model, click Yes. Set the following properties for the Recordset: <ol style="list-style-type: lower-alpha;"> Set Connection to the name of the Data Connection that you created in step 1.</li> Set Database Object to Tables.</li> Set Object Name to the name of a table in your database.</li></ol> </li> <li>Drag a Textbox DTC from the toolbox, and place it in the <BODY> section of your ASP page after the Recordset DTC. Right-click the Textbox DTC, and click Properties. In the resultant dialog box, set the following properties:

<ol style="list-style-type: lower-alpha;"> <li>Set Recordset to the Recordset DTC that you created in step 4.</li> <li>Set Field to a valid field name in your database.</li></ol>

Click OK.</li> <li>Drag a Button DTC from the toolbox, and place it in the <BODY> section of your ASP page after the Recordset DTC. Right-click the Button DTC, and select Properties. In the resultant dialog box, set the following properties:

<ol style="list-style-type: lower-alpha;"> <li>Set Name to btnUpdate.</li> <li>Set Caption to Update.</li></ol>

Click OK.</li> <li> Paste the following client-side JavaScript code in the heading section of your page: <SCRIPT LANGUAGE=javascript>

</SCRIPT> </li> <li>You can now change and update the value in the textbox. When you click the Update button, the validation script tests if the value is &quot;Test Value.&quot; If it is, the data is updated. Otherwise, a message box warns that the value is not correct, and the update event is cancelled.</li></ol>

<div class="references_section">