473,695 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

deriving from textbox control

Hi,
I'm trying to control the foreground and background colors of a textbox. I
hate that light gray foreground when the textbox.enabled =false. I've tried
to derive a control from the textbox, but I get the following error when
trying to run a page with the control on it. wc is the name of my class,
and exp is the name of my project.

Parser Error Message: 'exp.wc' is not a valid base class because it does not
extend class 'System.Web.UI. UserControl'.

Source Error:
Line 1: <%@ Control Language="vb" AutoEventWireup ="false"
Codebehind="wc. ascx.vb" Inherits="exp.w c"
TargetSchema="h ttp://schemas.microso ft.com/intellisense/ie5" %>

And here's the code:

Imports System
Imports System.Web.UI
Imports System.Web.UI.W ebControls

Public Class wc
Inherits System.Web.UI.W ebControls.Text Box

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

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

#End Region

'Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
' 'Put user code to initialize the page here
'End Sub

Protected Overrides Sub OnPreRender(ByV al e As System.EventArg s)
If Me.Enabled Then
Me.BackColor = Color.FromName( "White")
Else
Me.BackColor = Color.FromName( "LightGray" )
End If
Me.ForeColor = Color.FromName( "Black")
End Sub
End Class

Can anyone explain to me why I get this error?

Nov 18 '05 #1
3 1591
TextBox is a WebControl, whereas a UserControl is an object all its own..
If you're using a UserControl, you need to add a TextBox TO the UserControl,
rather then inheriting it.

Your other option is to create a web custom control that inherits the
textbox, and then you can use an @Register directive to include it on an
aspx page.


"Lisa Calla" <sp****@herplac e.com> wrote in message
news:gZ******** ************@ea tel.net...
Hi,
I'm trying to control the foreground and background colors of a textbox. I hate that light gray foreground when the textbox.enabled =false. I've tried to derive a control from the textbox, but I get the following error when
trying to run a page with the control on it. wc is the name of my class,
and exp is the name of my project.

Parser Error Message: 'exp.wc' is not a valid base class because it does not extend class 'System.Web.UI. UserControl'.

Source Error:
Line 1: <%@ Control Language="vb" AutoEventWireup ="false"
Codebehind="wc. ascx.vb" Inherits="exp.w c"
TargetSchema="h ttp://schemas.microso ft.com/intellisense/ie5" %>

And here's the code:

Imports System
Imports System.Web.UI
Imports System.Web.UI.W ebControls

Public Class wc
Inherits System.Web.UI.W ebControls.Text Box

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

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

#End Region

'Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
' 'Put user code to initialize the page here
'End Sub

Protected Overrides Sub OnPreRender(ByV al e As System.EventArg s)
If Me.Enabled Then
Me.BackColor = Color.FromName( "White")
Else
Me.BackColor = Color.FromName( "LightGray" )
End If
Me.ForeColor = Color.FromName( "Black")
End Sub
End Class

Can anyone explain to me why I get this error?

Nov 18 '05 #2
Ah, thanks for clearing that up.

"Sam Fields" <sf*****@jumpth egun.com> wrote in message
news:e7******** ******@TK2MSFTN GP15.phx.gbl...
TextBox is a WebControl, whereas a UserControl is an object all its own..
If you're using a UserControl, you need to add a TextBox TO the
UserControl,
rather then inheriting it.

Your other option is to create a web custom control that inherits the
textbox, and then you can use an @Register directive to include it on an
aspx page.


"Lisa Calla" <sp****@herplac e.com> wrote in message
news:gZ******** ************@ea tel.net...
Hi,
I'm trying to control the foreground and background colors of a textbox.

I
hate that light gray foreground when the textbox.enabled =false. I've

tried
to derive a control from the textbox, but I get the following error when
trying to run a page with the control on it. wc is the name of my class,
and exp is the name of my project.

Parser Error Message: 'exp.wc' is not a valid base class because it does

not
extend class 'System.Web.UI. UserControl'.

Source Error:
Line 1: <%@ Control Language="vb" AutoEventWireup ="false"
Codebehind="wc. ascx.vb" Inherits="exp.w c"
TargetSchema="h ttp://schemas.microso ft.com/intellisense/ie5" %>

And here's the code:

Imports System
Imports System.Web.UI
Imports System.Web.UI.W ebControls

Public Class wc
Inherits System.Web.UI.W ebControls.Text Box

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

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

#End Region

'Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
' 'Put user code to initialize the page here
'End Sub

Protected Overrides Sub OnPreRender(ByV al e As System.EventArg s)
If Me.Enabled Then
Me.BackColor = Color.FromName( "White")
Else
Me.BackColor = Color.FromName( "LightGray" )
End If
Me.ForeColor = Color.FromName( "Black")
End Sub
End Class

Can anyone explain to me why I get this error?


Nov 18 '05 #3
Hello Lisa,

Gosh... wouldnt the easier alternative be to use CSS?

input {
border: 1px solid black;
}

--
Matt Berther
http://www.mattberther.com
Hi,
I'm trying to control the foreground and background colors of a
textbox. I
hate that light gray foreground when the textbox.enabled =false. I've
tried
to derive a control from the textbox, but I get the following error
when
trying to run a page with the control on it. wc is the name of my
class,
and exp is the name of my project.
Parser Error Message: 'exp.wc' is not a valid base class because it
does not extend class 'System.Web.UI. UserControl'.

Source Error:

Line 1: <%@ Control Language="vb" AutoEventWireup ="false"
Codebehind="wc. ascx.vb" Inherits="exp.w c"
TargetSchema="h ttp://schemas.microso ft.com/intellisense/ie5" %>

And here's the code:

Imports System
Imports System.Web.UI
Imports System.Web.UI.W ebControls
Public Class wc
Inherits System.Web.UI.W ebControls.Text Box
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
End Sub

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

'Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
' 'Put user code to initialize the page here
'End Sub
Protected Overrides Sub OnPreRender(ByV al e As System.EventArg s)
If Me.Enabled Then
Me.BackColor = Color.FromName( "White")
Else
Me.BackColor = Color.FromName( "LightGray" )
End If
Me.ForeColor = Color.FromName( "Black")
End Sub
End Class
Can anyone explain to me why I get this error?


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
4088
by: Steven T. Hatton | last post by:
This may be another question having an obvious answer, but I'm not seeing it. I'm trying to create a class that derives from std::valarray<std::string>. I don't need a template, and I haven't come across any examples of a construct like what I show below. Perhapes it's simply a bad idea. If there is something fundamentally wrong with this approach please let me know. Can anybody tell me if there is a way to get the following to work? I...
0
2877
by: Mark Johnson | last post by:
The last reply got sort of cutoff. So here again: So for anyone interested, here's the simple regexp patterns for the substitutions required. The textbox control is being 'zoomed' in a popup which uses a web browser control. As soon as any numeric entity gets put into the browser control, it's lost. It will display properly. But it can't be then read back out with document.body.innerHTML (or outerHTML). It's
2
8393
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
2
3912
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow javascript checks for things like valid e-mail addresses or phone numbers (without having to add a separate control for validation). One idea I did some work on was having the control implement the IValidator interface and basically recreating...
0
1230
by: Dot net work | last post by:
Hi, Make up a very simple project as follows: 1 aspx form 3 web user controls (referred to as A, B, and C) "A" web user control: Put 1 textbox and 1 button on this web user control. (You must do this exactly!)
7
2125
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the following: (TextBox)UserPrefix=(TextBox)e.Item.Cells.Controls; string strUserPrefix=UserPrefix.Text; I keep getting the following error and I don't know why because I have declared the UserPrefix as a textbox using "protected...
4
2696
by: Samy | last post by:
Hi There, I have a user control with a textbox and a button which when clicked opens a calendar control(calendar.aspx page). When I select a date from the calendar control, the date is supposed to be populated in the textbox. I use the user control on a index.aspx page. In order to achieve this I have a selected intexchange event on the calendar control. I pass the textbox id using the querystring when the button is clicked and then...
2
19856
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
8
36885
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { txtDummie.BackColor=Color.Red; }
0
8640
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9122
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9001
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7670
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4587
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3018
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.