I'm creating a web control that has an image and a text box. I would
like to then override the Visible and Text property of the
usercontrol, so when you reference the visible property of the user
control it only set the visible property of the textbox.
When i call these newly created property I get the following error:
Object reference not set to an instance of an object.
Does anybody have any idea? Thank you.
Here is the code:
public abstract class DateSelector : System.Web.UI.U serControl
{
//protected System.Web.UI.W ebControls.Labe l lbl_Date;
protected System.Web.UI.W ebControls.Text Box txt_Date;
protected System.Web.UI.W ebControls.Imag e imgCalendar;
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
string scriptStr = "javascript:ret urn popUpCalendar(t his," +
getClientID() + @", 'mm/dd/yyyy', '__doPostBack(\ '" + getClientID() +
@"\')')";
imgCalendar.Att ributes.Add("on click", scriptStr);
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
public string getClientID()
{
return txt_Date.Client ID;
}
public string Text
{
get
{
return txt_Date.Text;
}
set
{
txt_Date.Text = value;
}
}
public override virtual bool Visible
{
get
{
return imgCalendar.Vis ible;
}
set
{
imgCalendar.Vis ible = value;
}
}
} 1 3094
this won't work. if your control is set to invisible, then its render
routine is not called. you should make a new property.
anyway the bug is your setting a property of one of your children, but
its not created yet. call ensurechildren first.
-- bruce (sqlwork.com)
Joshua wrote:
I'm creating a web control that has an image and a text box. I would
like to then override the Visible and Text property of the
usercontrol, so when you reference the visible property of the user
control it only set the visible property of the textbox.
When i call these newly created property I get the following error:
Object reference not set to an instance of an object.
Does anybody have any idea? Thank you.
Here is the code:
public abstract class DateSelector : System.Web.UI.U serControl
{
//protected System.Web.UI.W ebControls.Labe l lbl_Date;
protected System.Web.UI.W ebControls.Text Box txt_Date;
protected System.Web.UI.W ebControls.Imag e imgCalendar;
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
string scriptStr = "javascript:ret urn popUpCalendar(t his," +
getClientID() + @", 'mm/dd/yyyy', '__doPostBack(\ '" + getClientID() +
@"\')')";
imgCalendar.Att ributes.Add("on click", scriptStr);
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
public string getClientID()
{
return txt_Date.Client ID;
}
public string Text
{
get
{
return txt_Date.Text;
}
set
{
txt_Date.Text = value;
}
}
public override virtual bool Visible
{
get
{
return imgCalendar.Vis ible;
}
set
{
imgCalendar.Vis ible = value;
}
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tee |
last post by:
Hi,
I have a usercontrol with a overridable/virtual method. On the usercontrol
onload, it will call this method.
Now I have a form that have a few of this usercontrol.
And I want to override the method in each usercontrol, how do I accomplish
this?
|
by: DotNetBBK |
last post by:
Hi,
I am using a custom text box, where I need to override TabSelection, as I
have to generate an event and based on that event, I need to do some
processing in other class, who is listening to that event. This thing works
fine, when I am stopping in the debugger for the event, but as soon as I
remove the breakpoint from the event handler method. This doesn't work and
even the release version of the software also doesn't work.
Following...
|
by: Diego |
last post by:
Hallo!
I have an HtmlTable with a UserControl into it.
Setting table.Visible = false all controls in table have .Visible =
false. Then, setting table.Visible = true all controls in table except
the usercontrol hav .Visible = true; the usercontrol.Visible is still
false.
Is this a bug? Is documented? What's wrong?
|
by: Syed Zaidi via .NET 247 |
last post by:
I am working on a small project in which i want to develop acustom toolbar skeleton for handling database navigation. I havecreated a usercontrol consist of a toolbar inherits fromusercontrol and winform holding that control. First I want toaccess the Click functionality of each toolbar button(usercontrol) in my winform which holding the usercontrol; secondlywants to override the methods of usercontrol in winformaccordingly to the click event of...
|
by: Syed Zaidi |
last post by:
Hello All
I am a newbie in VB.NET and wanting to create a toolbar(User Control) for Database Navigation. What exactly I want is to have a user control which is inherited from the system.windows.forms. usercontrol and contain a toolbar which have buttons for navigating records. And the client Windows Form which owns that control must overrides the navigation methods of user control. Forexample to add some custom functionality for moving to first...
| |
by: Marc Robitaille |
last post by:
Hello,
Hello,
I developed a UserControl. It has funny behavior. It is composed of three
controls. A texbox, a combobox and a button. There are three properties to
indicate the visibility of the three controls. The only property which
functions well is the one for the button. The two others, even if I do:
UserControl.TextboxVisible = True or UserControl.ComboboxVisible = True, the
textbox or the combobox remain invisible. I placed a...
|
by: David Veeneman |
last post by:
I'm having trouble implementing a UserControl base property in a user
control that I am writing. My user control wraps a group box that contains
several radio buttons. I want to wire the user control's Text property to
the group box's Text property, like this:
public override string Text
{
get { return groupBox1.Text; }
set { groupBox1.Text = value; }
|
by: Dom |
last post by:
I have a usercontrol, and I am trying to write a Property called
"Text", but the compiler tells me that the Usercontrol class already
has a member called "Text". When I look (in intellisense, or help) I
don't see the member. I can easily override or make it new, but I'd
like to know what is going on.
Dom
|
by: Maddy |
last post by:
I need to populate a treeview from a text file. The data in it is in
the following form
1. (Parent Node)
(a) (Child Node)
(b) (Child Node)
..
..
..
(k) (Child Node)
|
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...
|
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,...
| |
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...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |