Calling a function in a user control to set an attribute in the code behind
I am currently trying to build a user control with a form. The form contains an asp:textbox element which has a custom attribute called data-source which I would like to set from a function in the code behind. The reason I need to use that attribute name is because I am using a premade autocomplete box which requires this name as the attribute name.
I have also tried several ways to insert the attribute into the ascx page from the ascx.cs page. I have tried to set the categories.data-source = categoryList(); (i have seen this in some online tutorials but this does not work). I have also tried to use AddAttribute in the Page_Load function but this does not seem to work for me either.
Does anyone have any ideas on what I can try in order to get the return string from the categoryList function to automatically complete the data-source attribute.
(Sorry for the basic question but I am a beginner at umbraco and c# .net.)
Calling a function in a user control to set an attribute in the code behind
I am currently trying to build a user control with a form. The form contains an asp:textbox element which has a custom attribute called data-source which I would like to set from a function in the code behind. The reason I need to use that attribute name is because I am using a premade autocomplete box which requires this name as the attribute name.
I have tried things like:
....
As long a the method categoryList() is returning a string, this should work (in you page_load method):
categories.Attributes.Add("data-source", categoryList());
Thanks - Works perfectly.
is working on a reply...