We help IT Professionals succeed at work.

Custom Control HELP

kanden
kanden asked
on
Medium Priority
275 Views
Last Modified: 2010-04-23
How do I access parameter data from a control:

<MC:MYCONTROL Runat="server" Id="MyControl1">
  <MYPARAMETER>My Input 1</MYPARAMETER>
 <MYPARAMETER>My Input 2</MYPARAMETER>
</MC:MYCONTROL>

Thanks
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Not enough information here.  What is MyParameter?  A collection?

Bob

Author

Commented:
I'm not sure.

I need  to set propertires from the control when I'm not sure how many there are. It might be a template or somthing like that.

Here is an example I have seen. How is this set-up in the .VB file.


<MYCONTROL:Parent  Runat="server">

<MYCONTROL:Child formfieldname="FNAME" dbfieldname="user_fname"></MYCONTROL:Child>
<MYCONTROL:Child formfieldname="LANME" dbfieldname="user_lname"></MYCONTROL:Child>
<MYCONTROL:Child formfieldname="ADDRESS" dbfieldname="user_address</MYCONTROL:Child>

</MYCONTROL:Parent>
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
What do you mean, "I'm not sure".  Are you inheriting a project that you didn't create?

What is MYCONTROL defined as?

Bob

Author

Commented:
"Are you inheriting a project that you didn't create?"

Yes, I am trying to recreate a control.

I am very new to custom controls, I have seen this done before were a child control is nested in a parent control. I am trying to exe a sqlcommand with indefinite number of parameters. Maybe you could just explain what ToolboxData is used for?

<ToolboxData("<{0}:DateTimeControl runat=server></{0}:DateTimeControl>"), ParseChildren(True)>

Thanks Sorry for the confusion
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
In the control project, is there a class called 'Parent', and one called 'Child'?

Bob

Author

Commented:
No,

this is hypothetical.

The ultimate goal is to understand what is going on.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
>>The ultimate goal is to understand what is going on.
So, you want me to explain something about which I have no understanding of either.  I can only make educated guesses at what you are even talking about.

Bob

Author

Commented:
Sorry Bob,

Maybe I need to wait until I understand a little more.

The main thing is understanding what ToolboxData is and does.

Gary
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
Gary,

Here is a good explanation of the metadata attributes that are useful when creating a custom web control:

Creating Web Custom Controls With ASP.Net 1.1 - Part III - Using Metadata Attributes
http://highertendencies.com/articles/237.aspx

<Quote>
ToolboxData Attribute
The ToolboxData attribute is assigned to a class and is where you define how the IDE will write the aspx xml data for the control when it is added from the toolbox. Where assemblies and their Namespaces are registered with an aspx page, one of the property values of the registration tag is the TagPrefix value that is associated with the assembly. The TagPrefix default value is cc1. This value should be picked up as a variable along with the rest of the toolbox data you specify in this attribute.

My ToolboxData attribute values normally follow this format:

    ToolboxData("<{0}:ImageButton runat=server></{0}:ImageButton>")

The {0} part of the value is where the TagPrefix value from the page registration is used. To not include this would be very dangerous. For the other part of the tag name, I have never had a reason to use a different value other than the class name of my control. The TagPrefix value ensures that there are no naming collisions. For example, I am creating this ImageButton control, but there is already the intrinsic ASP.Net ImageButton control. The ASP.Net control is declared as ASP:ImageButton and with a TagPrefix value of cc1 my ImageButton control will be declared as cc1:ImageButton. By default I also need the runat= server declaration put in.

</Quote>

Bob

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.