473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Custom Server Control Property

Joe
I wrote a simple server control that inherits from the DropDownList
control. I will be using the control in an aspx page and want to
access it in a repeater. I have created a public property called
DefaultValue. For some reason, the property is never set from within
my aspx page. It just gets ignored. Does anyone know why?

Here is how it looks in my aspx:
--------------------------------------------------------

<frmcontrol:controltypedropdown DefaultValue="5"
id="Controltypedropdown1" runat="server"/>

----------------------------------------------------------
Below is my control code.
-----------------------------------------------------------

namespace blah.Controls
{

/// <summary>
/// A server control to display the dropdown of Control Types. Will
be
/// displayed programatically in a repeater.
/// </summary>
public class ControlTypeDropDown :
System.Web.UI.WebControls.DropDownList
{
private DataTable dt;
private ListItem[] coll;

private string defaultValue="0";
public string DefaultValue
{
get{return defaultValue;}
set{defaultValue=value;}
}

public ControlTypeDropDown() : base()
{
lock(this)
{
if(HttpContext.Current.Application["ControlTypeDropDown"]==null)
{
Survey s = new Survey();
dt = s.GetFormControls();
coll = new ListItem[dt.Rows.Count+1];
coll[0] = new ListItem("", "0");
for(int i=0;i<dt.Rows.Count;i++)
{
coll[i+1] = new ListItem(Convert.ToString(dt.Rows[i]["type"]),
Convert.ToString(dt.Rows[i]["controlTypeId"]));
}

HttpContext.Current.Application.Add("ControlTypeDr opDown", coll);
}
else
{
coll = (ListItem[])HttpContext.Current.Application["ControlTypeDropDown"];
}

this.Items.AddRange(coll);
this.Items.FindByValue(DefaultValue).Selected=true ;
}
}


}
}
Nov 17 '05 #1
0 983

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

Similar topics

0
by: Joe | last post by:
I am having a hard time with setting a property on a custom server control that i am placing in a repeater. The control inherits from DropDownList. The property is being set in the repeater using...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
3
by: Chris Newby | last post by:
I have a very simple custom control that derives from WebControls.Panel and implements INamingContainer. It appear that controls created as children of my custom control are having ViewState...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
1
by: Jeremy Chapman | last post by:
I have a property will an array of webcontrols. The control features a custom property editor which can add and remove web controls to the array, but how do I persist the informtion by...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
3
by: Tomasz J | last post by:
Hello Developers, I have a control derived from System.Web.UI.WebControls.WebControl. Control has this property: public string Value { set { _value = value; } get { return _value; }
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
4
by: Jeff | last post by:
hi asp.net 2.0 I have created a custom web control, here is it's header: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditUserBox.ascx.cs" Inherits="Controls_EditUserBox" %> ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.