usercontrol problem

  • Thread starter Thread starter bill yeager
  • Start date Start date
B

bill yeager

When trying to run my web project, I get the following
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: The base class includes the
field 'ValidateLogin', but its type
(YTCIWebUserControls.UserLogin) is not compatible with the
type of control (ASP.UserLogin_ascx).

Source Error:


Line 13: <form id="Login" runat="server">
Line 14: <p></p>
Line 15: <YTCI:LoginControl
runat="server" id="ValidateLogin"></YTCI:LoginControl><BR>
Line 16: <div align="center">
Line 17: <asp:button
id="btnOK" runat="server"
Text="OK"></asp:button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


Source File: C:\Inetpub\wwwroot\NCVAC\logon.aspx Line:
15



All this is, is a usercontrol with a login screen as
follows:

'usercontrol html
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="UserLogin.ascx.vb"
Inherits="YTCIWebUserControls.UserLogin"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5
" %>
<h3 align="center"><font face="Verdana">Logon Page</font>
</h3>
<table align="center">
<tr>
<td><asp:label id="lblUserID" Text="User
ID:" Font-Bold="true" runat="server"></asp:label></td>
<td><asp:textbox id="txtUserID"
runat="server" MaxLength="20"></asp:textbox></td>
<td><ASP:REQUIREDFIELDVALIDATOR
id="vUserName" runat="server"
ControlToValidate="txtUserID" ErrorMessage="UserID is
required"

Display="Static"></ASP:REQUIREDFIELDVALIDATOR></td>
</tr>
<tr>
<td><asp:label id="lblPassword"
Text="Password:" Font-Bold="true"
runat="server"></asp:label></td>
<td><asp:textbox id="txtPassword"
runat="server" TextMode="Password"
MaxLength="20"></asp:textbox></td>
<td><ASP:REQUIREDFIELDVALIDATOR
id="vUserPass" runat="server"
ControlToValidate="txtPassword" ErrorMessage="Password is
required"

Display="Static"></ASP:REQUIREDFIELDVALIDATOR></td>
</tr>
<tr>
<td>Persistent Cookie:</td>
<td><ASP:CHECKBOX id="chkPersistCookie"
runat="server" autopostback="false"></ASP:CHECKBOX></td>
<td></td>
</tr>
</table>

'usercontrol vb code

Public MustInherit Class UserLogin
Inherits System.Web.UI.UserControl

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents vUserName As
System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents vUserPass As
System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents chkPersistCookie As
System.Web.UI.WebControls.CheckBox
Protected WithEvents lblMsg As
System.Web.UI.WebControls.Label
Protected WithEvents lblUserID As
System.Web.UI.WebControls.Label
Protected WithEvents txtUserID As
System.Web.UI.WebControls.TextBox
Protected WithEvents lblPassword As
System.Web.UI.WebControls.Label
Protected WithEvents txtPassword As
System.Web.UI.WebControls.TextBox

'NOTE: The following placeholder declaration is
required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Public Property UserID() As String
Get
UserID = txtUserID.Text
End Get
Set(ByVal Value As String)
txtUserID.Text = Value
End Set

End Property

Public Property Password() As String
Get
Password = txtPassword.Text
End Get
Set(ByVal Value As String)
txtPassword.Text = Value
End Set

End Property

Public Property PersistantCookie() As Boolean
Get
PersistantCookie = chkPersistCookie.Checked
End Get
Set(ByVal Value As Boolean)
chkPersistCookie.Checked = Value
End Set

End Property

End Class

'aspx html that incorporates my usercontrol
<%@ Register TagPrefix="YTCI" TagName="LoginControl"
Src=".\UserControls\UserLogin.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Logon.aspx.vb" Inherits="NCVAC.ValidateLogin" %<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<title>Login</title>
<meta content="Microsoft Visual
Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1"
name="CODE_LANGUAGE">
<meta content="JavaScript"
name="vs_defaultClientScript">
<meta
content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Login" runat="server">
<p></p>
<YTCI:LoginControl runat="server"
id="ValidateLogin"></YTCI:LoginControl><BR>
<div align="center">
<asp:button id="btnOK"
runat="server"
Text="OK"></asp:button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:button id="btnClear"
runat="server" Text="Clear"></asp:button><br>
</div>
</form>
</body>
</HTML>

'aspx vb code that incorporates the usercontrol
Public Class ValidateLogin
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents btnOK As
System.Web.UI.WebControls.Button
Protected WithEvents btnClear As
System.Web.UI.WebControls.Button

'NOTE: The following placeholder declaration is
required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private strUserName As String
Private exException As Exception()
Protected ValidateLogin As
YTCIWebUserControls.UserLogin

Private Sub btnClear_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnClear.Click
ValidateLogin.UserID = String.Empty
ValidateLogin.Password = String.Empty
End Sub

Private Sub btnOK_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnOK.Click

Dim strDataSource As String
strDataSource = CType(Application
("strDataSource"), String)

Dim clsBLL As New NCVACBLL.Scheduling
(strDataSource)
Dim drOLEDBNCVAC As OleDbDataReader

Try
Cursor.Current =
System.Windows.Forms.Cursors.WaitCursor
drOLEDBNCVAC = clsBLL.GetUserInfo
(ValidateLogin.UserID, ValidateLogin.Password)
..
..
..
I'm really pulling my hair out over this one! I've tried
so many different things to get this to work.... Can
someone please HELP!!

Thanks so much,

Bill.....
 
I didn't read into your code cause there's a lot but from
the error message it looks as if you specify ValidateLogin
control of type YTCI:LoginControl in your aspx page, but
in the codebehind member ValidateLogin is declared of some
other type. this happens a lot when your member variables
are out of sink with the id's in the page. for instance if
you have <asp:Label id="lbl"> but in the code you declare

TextBox lbl; -> then you will get a runtime error...
 
I FINALLY figured it out!

All I did was change the line:

Protected ValidateLogin As YTCIWebUserControls.UserLogin
to
Protected ValidateLogin As UserLogin

in my codebehind page....
-----Original Message-----
I didn't read into your code cause there's a lot but from
the error message it looks as if you specify ValidateLogin
control of type YTCI:LoginControl in your aspx page, but
in the codebehind member ValidateLogin is declared of some
other type. this happens a lot when your member variables
are out of sink with the id's in the page. for instance if
you have <asp:Label id="lbl"> but in the code you declare

TextBox lbl; -> then you will get a runtime error...



ie Inherits="NCVAC.ValidateLogin"
<script language="JavaScript">
<!--

window.open = SymRealWinOpen;

//-->
</script>
 
Back
Top