Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2006, 03:25 AM
Authorized User
 
Join Date: Apr 2006
Posts: 79
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via AIM to anujrathi Send a message via MSN to anujrathi Send a message via Yahoo to anujrathi
Default Problem in accessing the usercontol properties

Hi,
  I am Anuj Rathi. I m facing a problem with usercontrol. I m not able to access the properties that are defined in usercontrol.

My prob is:

 I hav a userControl in which i hav placed 3 DropDownListBox or (these can be listboxes), for hours(0-12), Minutes(0-60) & AM/PM. & write the properties in .ascx.cs for accessing the values in my .aspx web page.

in the page load event of the user control, i hav written

if(! IsPostBack)
{
 for(int i=0;i<=12;i++)
 {
  if(i<=9)
   ddlHours.Items.Add(new ListItem("0" + i));
 else
  ddlHours.Items.Add(new ListItem(Convert.ToString(i)));
 }
}

& define the properties as follows:

public string Hours
{
get
 {
   return ddlHours.SelectedItem.ToString();
 }
}


I hav also import the UserControl's namespace, in the aspx page.

But when i m trying to access the value of the ddlHours in my page with button's click event:

DateTimePicker dtp = new DateTimePicker(); // Create object
Response.Write(dtp.Hours);

It gives an error

"Object reference not set to an instance of an object"

pls give me a proper solution.!!!!!!!
 
Old June 8th, 2006, 02:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

In the code-behind page of the web page, you have to add the protected withevents <controlname> as <controltype> manually.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Dataset Properties kjward BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 November 16th, 2006 01:18 PM
Problem in accessing the UserControl properties anujrathi ASP.NET 1.0 and 1.1 Professional 1 June 8th, 2006 02:13 PM
Accessing Properties in User Controls andyj00 ASP.NET 1.0 and 1.1 Professional 16 August 1st, 2005 07:55 AM
Accessing Properties in User Controls andyj00 Classic ASP Professional 1 May 21st, 2005 02:52 PM
accessing Macros properties with vba rle123 Access VBA 0 July 17th, 2003 04:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.