473,890 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Override Text and Visible in System.Web.UI.U serControl

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;
}
}
}

Oct 19 '07 #1
1 3146
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;
}
}
}
Oct 19 '07 #2

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

Similar topics

3
334
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?
0
1105
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...
0
984
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?
0
1465
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...
2
2800
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...
6
9221
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...
2
4197
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; }
5
1645
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
2
3471
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)
0
9976
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
9815
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
11215
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
10802
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
9618
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...
0
5835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4665
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
2
4259
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.