C# - Get Custom Attribute from Control

Posted on 2013-09-26
Medium Priority
Last Modified: 2013-09-26
I have the below code.  While I'm looping through the controls on the code behind how do I get the value of the custom attribute "CustAttribute"?

<asp:textbox id="txtPlace" runat="server" CustAttribute="Enable">

Open in new window

Question by:CipherIS
1 Comment
LVL 15

Accepted Solution

unknown_routine earned 2000 total points
ID: 39525843
You need this:

string customAttrData = txtPlace.Attributes["CustAttribute"].ToString();

You need to note that Custom Attribues do not get forwarded to the server.

so you need to use the viewstate to preserve them.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question