Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create a custom attribute for a control and have access to it in my asp.net page. All I need to do is store a simple string and have its value visable in my asp page (for clarity).

One example of what I am doing is using a validation control and I need two values. The first value is what is displayed on the page for the control using the "Error Message" attribute. I then iterate through the controls to create a summary text file with detailed info. I am currenty using the tooltip field to store the details.

ErrorMessage="Required"
ToolTip="The validation error you have encountered..."

then

for each validator...
if (!validator.IsValid)
... concatenate ToolTip + CHAR(13)...

I would like to create additional attributes I can set in the asp page like:

<asp:textbox id=... runat=... MyAttribute1=... MyAttribute2=

I know I can manage custom attributes from C# using the .attribute collection, but the attributes are not available in the asp page (from what I have seen). I have also seen (somewhat) complex approaches using [Attribute... on classes with overrides Both approaches seem complex for my needs.

THanks
Posted
Comments
Sandeep Mewara 4-May-10 15:14pm    
Use 'Add Comments' feature to discuss the answer(s) instead of using answers button!

hey check this articles which in which i have created custom control with my custom attributes and used by me in my javascript

hope this will help

VB
<a href="http://www.codeproject.com/KB/aspnet/RequiredField.aspx">Generic Code of Validating Fields with Jquery</a>

<a href="http://www.codeproject.com/KB/validation/MyTextBox.aspx">Enhanced Textbox Control</a>
 
Share this answer
 
u cant uses ViewState?!?!?!?.....................
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900