I am dynamically populating the ID of a textbox which is saved in my database. I am setting it as a string when pulling the value out of a data set which determines the parameters for a search.
I now want to use the string parameter as the dynamic ID for an Attributes.Add method using a Client ID. The end result I need, is to populate a Date Picker for an ASP:Textbox, with an onfocus event.
Example as follows:
//setting the value of the item from the dataset
string textCode = ds.Tables["CONTROLS"].Rows[1]["TEXTCODE"].ToString();
//inserting the value for use with ClientID
textCode.Attributes.Add("onfocus", "datepicker('" + textCode.ClientID + "');");
I am getting the error of: "'string' does not contain a definition for 'ClientID' accepting a first argument of 'string' could be found (are you missing a using directive or an assembly reference")".
When I attempt to convert or set another variable to an HtmlControl which ClientID is available for as such:
HtmlControl txtCode = textCode;
I get the following error: "Cannot implicitly convert 'string' to 'System.Web.UI.HtmlControls.HtmlControl'"
How do I convert to use this dynamic ID?
Thank you in advance for your suggestions.