Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 21st, 2006, 01:57 PM
Authorized User
 
Join Date: Aug 2005
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default Control validator

What is wrong with my custom validator when it won't work?
All other validators works fine but custom validator won't.
Could someone help me
<%@ Control Language="VB" debug="true" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicK eyToken=836f606ede05d46a,culture=neutral" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.text" %>
<MM:DataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_Home") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_Home") %>'
CommandText='<%# "SELECT * FROM dbo.LoginRegPageTxT WHERE LangID = @LangID and Page = @Page" %>'
Debug="true"
>
  <Parameters>
    <Parameter Name="@LangID" Value='<%# IIf((Not Request.Cookies("LangID") Is Nothing), Request.Cookies(IIf((Not Request.Cookies("LangID") Is Nothing), "LangID", 0)).Value, "") %>' Type="Int" />
    <Parameter Name="@Page" Value='<%# IIf((Request.QueryString("Page") <> Nothing), Request.QueryString("Page"), "") %>' Type="Char" />
  </Parameters>
</MM:DataSet>
<MM:DataSet
id="DataSet2"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_Home") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_Home") %>'
CommandText='<%# "SELECT * FROM dbo.page_small_text WHERE Langid = @LangID AND Page = @Page" %>'
Debug="true"
>
  <Parameters>
    <Parameter Name="@LangID" Value='<%# IIf((Not Request.Cookies("LangID") Is Nothing), Request.Cookies(IIf((Not Request.Cookies("LangID") Is Nothing), "LangID", 0)).Value, "") %>' Type="Int" />
    <Parameter Name="@Page" Value='<%# IIf((Request.QueryString("Page") <> Nothing), Request.QueryString("Page"), "") %>' Type="Char" />
  </Parameters>
</MM:DataSet>
<MM:DataSet
id="ControlUser"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_Home") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_Home") %>'
CommandText='<%# "SELECT Username FROM dbo.Login WHERE Username = @Username" %>'
Debug="true"
>
  <Parameters>
    <Parameter Name="@Username" Value='<%# IIf((Request.Form("Username") <> Nothing), Request.Form("Username"), "") %>' Type="NVarChar" />
  </Parameters>
</MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<script runat="server">
protected sub serverVal(sender as Object ,args as ServerValidateEventArgs)
    if ControlUser.RecordCount > 1 Then
        args.IsValid = false
    else
        args.IsValid = true
    end if
end sub

protected sub Page_Load(Src as Object ,E as EventArgs)

  if (IsPostBack)
      Page.Validate()
If Page.IsValid then
    response.write("true")
    'regUser.Expression = True
    'regUser.Doinit()
    'regUser.Expression = false
'Dim loConn as SqlConnection
'Dim myCommand as SqlCommand
'Dim InsertCmd as String
'loConn = New SqlConnection("Server=HWBLOFA; database=home_net; UID=sa; PWD=Hwboys80")
'insertCmd = "insert into Login (Username, Password, email, Active, Activationcode) values (@Username, @Password, @email, @Active, @Activationcode)"
'myCommand = New SqlCommand(InsertCmd, loConn)
'myCommand.Parameters.Add(New SqlParameter("@UID", SqlDBType.int))
'myCommand.Parameters("@UID").Direction = ParameterDirection.Output
'myCommand.Parameters.Add(New SqlParameter("@Username", SqlDbType.nVarChar, 50))
'myCommand.Parameters("@Username").value = Username.value
'myCommand.Parameters.Add(New SqlParameter("@Password", SqlDbType.nVarChar, 50))
'myCommand.Parameters("@Password").value = Password.value
'myCommand.Parameters.Add(New SqlParameter("@email", SqlDbType.nVarChar, 50))
'myCommand.Parameters("@email").value = email.value
'myCommand.Parameters.Add(New SqlParameter("@Active", SqlDbType.int))
'myCommand.Parameters("@Active").value = "0"
'myCommand.Parameters.Add(New SqlParameter("@Activationcode", SqlDbType.nVarChar, 50))
'myCommand.Parameters("@Activationcode").value = activecode.value
'myCommand.Connection.open()
'myCommand.ExecuteNonQuery()
'myCommand.Connection.Close()
    else
response.Write("false")
    end if
end if
If request.Cookies("LangID").value = "1" then
user.text = "Username"
paswd.text = "Password"
Cpaswd.text = "Confirm Password"
emails.text = "Email"
end if
End Sub


</script>
<script runat="server">

</script>


<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div align="Left" class="MenuHeader"><%# DataSet1.FieldValue("Header", Container) %>
    </div></td>
  </tr>
  <tr>
    <td height="20"></td>
  </tr>
</table>
<form name='reg' method='POST' action="" runat="server">
    <table width="100%" border="0" cellspacing="1" cellpadding="1">
      <tr>
        <td colspan="2"><%# DataSet1.FieldValue("PageTxT", Container) %></td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td width="21%"><div align="right">
          <asp:Label ID="User" runat="server" />
          </div></td>
        <td width="79%"><input id="Username" name="Username" type="text" runat="server" />
                <asp:requiredfieldvalidator ControlToValidate="username" Display="Dynamic" errormessage="Username Field Needs to Fill" Text="*" ID="requsername" runat="server" />
                <asp:customvalidator OnServerValidate="serverVal" ControlToValidate="Username" ID="checkusername" runat="server" Display="Dynamic" ErrorMessage="Username allready exists choose another" Text="*" />

        </td>
      </tr>
<tr>
        <td><div align="right">
          <asp:Label ID="emails" runat="server" />
</div></td>
      <td><input type="text" id="email" name="email" runat="server">
          <asp:requiredfieldvalidator ControlToValidate="email" Display="Dynamic" ErrorMessage="E-mail Field Needs to Fill" Text="*" ID="reqemail" runat="server" />
          <asp:regularexpressionvalidator ControlToValidate="email" Display="Dynamic" ErrorMessage="Your E-mail address is not well formed" Text="*" ID="checkemail" ValidationExpression="[\w\.-]+(\+[\w-]*)?@([\w-]+\.)+[\w-]+" runat="server" />
      </td>
      </tr>
      <tr>
        <td>
          <div align="right">
            <asp:Label ID="Paswd" runat="server" />
          </div></td>
      <td> <input id="Password" name="password" type="password" runat="server">
<asp:requiredfieldvalidator ControlToValidate="password" Display="Static" ErrorMessage="Password Field Needs to Fill" Text="*" ID="reqpass" runat="server" />
<asp:CompareValidator ControlToCompare="password" ControlToValidate="Username" Display="Static" ErrorMessage="Password can't be same as Username" ID="Passvalidate" Operator="NotEqual" runat="server" Text="*" Type="String" />
      </td>
      </tr>
      <tr>
        <td><div align="right"><asp:Label ID="Cpaswd" runat="server" /></div></td>
      <td><input id="cpassword" name="cpassword" type="password" runat="server">
          <asp:requiredfieldvalidator ControlToValidate="CPassword" Display="Dynamic" ErrorMessage="Confirm Password Field Needs to Fill" Text="*" ID="reqcpass" runat="server" />
  <asp:comparevalidator ControlToCompare="password" ControlToValidate="Cpassword" Display="static" ErrorMessage="The password do not match." Text="The passwords do not match." ID="valpass" runat="server" />

      </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input id="activecode" name="activecode" type="hidden" runat="server" value="<%#System.Guid.NewGuid().ToString()%>" ></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type="submit" value='<%# DataSet2.FieldValue("Txt", Container) %>' runat="server"> </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><asp:ValidationSummary ID="summary" runat="server" DisplayMode="BulletList" ShowSummary="true"></asp:ValidationSummary></td>
      </tr>
  </table>



</form>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Use 1 control validator to multiple textbox contro marvz ASP.NET 2.0 Basics 2 July 27th, 2011 02:03 AM
validator control error amit.jagtap ASP.NET 1.0 and 1.1 Basics 2 October 1st, 2007 07:07 AM
Error rendering Validator control bmains General .NET 0 July 27th, 2005 03:45 PM
DataGrid Controls Within custom validator control geetha_ganesan ADO.NET 1 March 26th, 2005 04:38 PM
How to check entered data with Validator Control minhpx General .NET 2 September 15th, 2004 04:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.