I don't know why I couldn't get this work:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace DateValidatorControl
{
public class DateValidator : BaseValidator
{
private TextBox DatetoValidTextBox;
public string _schedule = null;
public string Schedule
{
get {
return _schedule;
}
set {
_schedule = value;
}
}
protected override bool EvaluateIsValid()
{
bool result;
Control ctrl = base.FindControl(base.ControlToValidate);
DatetoValidTextBox = (TextBox)ctrl;
string DatetoValid = DatetoValidTextBox.Text.ToString();
string connectStr = "server=10.1.1.1; uid=; pwd=; database=Temporary";
string SSQL = "Select ddate from TseparateD where schedule = '" + _schedule + "' and ";
SSQL = SSQL + "ddate = '" + DatetoValid + "'";
SqlConnection connectObj = new SqlConnection(connectStr);
SqlCommand commandObj = new SqlCommand(SSQL, connectObj);
SqlDataReader readerObj;
connectObj.Open();
readerObj = commandObj.ExecuteReader();
if(readerObj.Read()) {
result=true;
}else{
result=false;
}
readerObj.Close();
connectObj.Close();
return result;
}
}
}
=================================================
It got a parser error:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: File or assembly name DateValidatorControl, or one of its dependencies, was not found.
Source Error:
Line 1: <%@ Page Language="C#" Debug="true" %>
Line 2: <%@ Register TagPrefix="MEC" Namespace="DateValidatorControl" Assembly="DateValidatorControl" %>
Line 3: <%@ Import Namespace="System.Data" %>
Line 4: <%@ Import Namespace="System.Drawing" %>
=================================================
any idea? I created another simple .dll file before, I can get that to work. So I think the location to pu the .dll should be correct. I am new to C#, sorry if it just got a stupid error.