Online Product Info
AutoInitiate Property

Description
ASP.NET Auto DB initiates form processing automatically when your form is posted. However, there are times when some people want Auto DB to execute only when a certain form button is pressed or after a certain condition is met. This is where the AutoInitiate property and Initiate() method come in.

AutoInitiate is set to True by default. This indicates that Auto DB should process your form as soon as a user submits your form (as long as form errors don't exist). By setting AutoInitiate to False, you are telling ASP.NET Auto Email that you will explicitly indicate when it should execute. You then call the Initiate() method to get Auto DB to execute when you want it to. 

So if you want precise control over Auto DB's execution time, simply set AutoInitiate="False" in the control tag...Then call the initiate() method in a button onclick handler or at the point you want ASP.NET Auto DB to execute.

Example
Let's say you have a form that includes two buttons. One button indicates that Auto DB should execute, the other button has another function (and Auto DB should not execute if it is pressed.)

You would simply set AutoInitiate="False", then call the Initiate() method in your button's onclick handler as shown in Listing A below:

<%@ Register TagPrefix="cc1" Namespace="By360Impact.AutoDB" Assembly="By360Impact.AutoDB" %>
<%@ Page Language="vb" %>

<script runat="server">
'****************************************
'* btnSubmit OnClick Handler
'* Where btnSubmit is the id of your button
'* Where AutoEmail1 is the id of your Auto DB control tag
'****************************************
Private Sub btnSumbit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
   AutoDB1.Initiate()
End Sub

</script>

<HTML>
<body>

<form id="Form1" method="post" runat="server"> 
<cc1:AutoDB id="AutoDB1" runat="server" AutoInitiate="False"></cc1:AutoDB>

Name: <asp:TextBox id="Name" runat="server"></asp:TextBox><br>
Age: <asp:TextBox id="Age" runat="server"></asp:TextBox><br><br>


<asp:Button id="btnSumbit" runat="server" OnClick="btnSumbit_Click" Text="Submit"></asp:Button>&nbsp;
<asp:Button id="btnOther" runat="server" Text="Other Process"></asp:Button></TD>
</form>

</body>
</HTML>

Listing A

Default Value
If you do not specify the AutoInitiate property, it will be set to True automatically.

Usage
See Listing B for an example of the AutoInitiate property in the Auto Email control tag.

<cc1:AutoDB id="AutoDB1" runat="server" AutoInitiate="True"> </cc1:AutoDB>
Listing B

 

© copyright 2004 360 IMPACT. All rights reserved.