Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating custom properties
Message
 
General information
Forum:
ASP.NET
Category:
Client-side development
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01335677
Message ID:
01335679
Views:
14
I think it's not as simple as just setting the attribute.

Here is a link
http://haacked.com/archive/2006/11/26/Adding_ClientSide_Custom_Properties_To_Controls.aspx

>Hi everybody,
>
>Do you know how can I add a custom property to a control?
>
>Here is the code I'm trying
>
>protected void Page_Load(object sender, EventArgs e)
>    {
>        string sConnString = ConfigurationManager.ConnectionStrings["FCCMSConnectionString"].ConnectionString;
>        SqlConnection oCn = new SqlConnection(sConnString);
>
>        SqlCommand Command = new SqlCommand("GetSchoolsBySiteID", oCn);
>        Command.CommandType = CommandType.StoredProcedure;
>
>        SqlParameter ParSiteID = new SqlParameter("@SiteID", this.GetParameter());
>
>        Command.Parameters.Add(ParSiteID);
>
>        Command.Connection.Open();
>
>        SqlDataReader oReader = Command.ExecuteReader();
>
>        while (oReader.Read())
>        {
>         ListItem li = new ListItem();
>           li.Attributes.Add("Phone", oReader["Phone"].ToString()) ;
>           li.Text = oReader["School"].ToString() ;
>           li.Value = li.Text;
>           this.ddlSchool.Items.Add(li);
>        }
>        oReader.Close();
>        oCn.Close();
>        this.ddlSchool.Attributes.Add("onchange","alert( this.options[this.selectedIndex].Phone);");
>    }
>
>
>However, JavaScript shows undefined all the time. Do you see what's wrong here or how can I create a new custom property and access it?
>
>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform