Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating custom properties
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Client-side development
Title:
Creating custom properties
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01335677
Message ID:
01335677
Views:
48
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
Next
Reply
Map
View

Click here to load this message in the networking platform