Answered
Validation Controls
Created a folrm to insert a recxord into a database.
Server behaviours created:
Insert Record.
ASP.NET E- Mail Validator.
ASP.NET Required Field.
Everything goes ok to the database however the validation controls do not seem to work.
In Visual Studio I wiould have created a button click event.
Private Sub Button1_Click(ByVal sender As System.Object, By Val e as System.EventArgs) handles Button1.Click)
If IsValid Then
Response.Redirect("Success.aspx")
End If
End Sub
How is this done in DW?
The page code as it stands is below.
<form method='POST' name='frmAddrecord' id="frmAddrecord" runat='server'>
<table width="70%" border="0" cellspacing="5" cellpadding="0" summary="Please use the following form to leave us a message.">
<caption>
Contact Us
</caption>
<tr>
<td width="20%">Name:</td>
<td width="48%">
<asp:TextBox ID="txtName" TextMode="SingleLine" runat="server" /> </td>
<td width="32%"><asp:RequiredFieldValidator id="reqName" runat="server" ControlToValidate="txtname" ErrorMessage="Required" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>E-Mail:</td>
<td><asp:TextBox ID="txtEmail" TextMode="SingleLine" runat="server" /></td>
<td><asp:RegularExpressionValidator id="valEmail" runat="server" ErrorMessage="E-Mail Required" ControltoValidate="txtEmail" ValidationExpression="[\w]+(\+[\w]*)?@([\w-]+\.)+[\w-]+"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>Comments:</td>
<td>
<asp:TextBox ID="txtComments" Rows="4" Columns="15" TextMode="MultiLine" runat="server" /> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnSubmit" Text="Submit" runat="server" />
<asp:Button ID="btnCancel" Text="Cancel" runat="server" /></td>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="frmAddrecord">
</form>
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:Insert
runat="server"
CommandText='<%# "INSERT INTO dbo.contactquery (contact_name, email, question) VALUES (@contact_name, @email, @question)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_conSQLPerenelle") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_conSQLPerenelle") %>'
Expression='<%# Request.Form("MM_insert") = "frmAddrecord" %>'
CreateDataSet="false"
SuccessURL='<%# "contact-sucess.aspx" %>'
FailureURL='<%# "contact-fail.aspx" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@contact_name" Value='<%# IIf((Request.Form("txtName") <> Nothing), Request.Form("txtName"), "") %>' Type="NChar" />
<Parameter Name="@email" Value='<%# IIf((Request.Form("txtEmail") <> Nothing), Request.Form("txtEmail"), "") %>' Type="NChar" />
<Parameter Name="@question" Value='<%# IIf((Request.Form("txtComments") <> Nothing), Request.Form("txtComments"), "") %>' Type="NChar" />
</Parameters>
</MM:Insert>
<MM
ageBind runat="server" PostBackBind="true"
/>
Server behaviours created:
Insert Record.
ASP.NET E- Mail Validator.
ASP.NET Required Field.
Everything goes ok to the database however the validation controls do not seem to work.
In Visual Studio I wiould have created a button click event.
Private Sub Button1_Click(ByVal sender As System.Object, By Val e as System.EventArgs) handles Button1.Click)
If IsValid Then
Response.Redirect("Success.aspx")
End If
End Sub
How is this done in DW?
The page code as it stands is below.
<form method='POST' name='frmAddrecord' id="frmAddrecord" runat='server'>
<table width="70%" border="0" cellspacing="5" cellpadding="0" summary="Please use the following form to leave us a message.">
<caption>
Contact Us
</caption>
<tr>
<td width="20%">Name:</td>
<td width="48%">
<asp:TextBox ID="txtName" TextMode="SingleLine" runat="server" /> </td>
<td width="32%"><asp:RequiredFieldValidator id="reqName" runat="server" ControlToValidate="txtname" ErrorMessage="Required" Display="Static"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td>E-Mail:</td>
<td><asp:TextBox ID="txtEmail" TextMode="SingleLine" runat="server" /></td>
<td><asp:RegularExpressionValidator id="valEmail" runat="server" ErrorMessage="E-Mail Required" ControltoValidate="txtEmail" ValidationExpression="[\w]+(\+[\w]*)?@([\w-]+\.)+[\w-]+"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td>Comments:</td>
<td>
<asp:TextBox ID="txtComments" Rows="4" Columns="15" TextMode="MultiLine" runat="server" /> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnSubmit" Text="Submit" runat="server" />
<asp:Button ID="btnCancel" Text="Cancel" runat="server" /></td>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="frmAddrecord">
</form>
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:Insert
runat="server"
CommandText='<%# "INSERT INTO dbo.contactquery (contact_name, email, question) VALUES (@contact_name, @email, @question)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_conSQLPerenelle") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_conSQLPerenelle") %>'
Expression='<%# Request.Form("MM_insert") = "frmAddrecord" %>'
CreateDataSet="false"
SuccessURL='<%# "contact-sucess.aspx" %>'
FailureURL='<%# "contact-fail.aspx" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@contact_name" Value='<%# IIf((Request.Form("txtName") <> Nothing), Request.Form("txtName"), "") %>' Type="NChar" />
<Parameter Name="@email" Value='<%# IIf((Request.Form("txtEmail") <> Nothing), Request.Form("txtEmail"), "") %>' Type="NChar" />
<Parameter Name="@question" Value='<%# IIf((Request.Form("txtComments") <> Nothing), Request.Form("txtComments"), "") %>' Type="NChar" />
</Parameters>
</MM:Insert>
<MM
