I face a strange problem to access some HtmlGenericControl which created in run time .
How to make the HtmlGenericControl runat ="server"?so i can access it
HtmlGenericControl myli = new HtmlGenericControl("li");
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Right because runat is interpeted at compile time it actually creates the control in the .designer file which is basically what you are doing in you .cs (code behind) So creating the control at runtime you need to manually create your Control tree, something that would happen automatically if you were using the designer.
I believe you would create some kind of Structure, Array, Dictionary etc. that would map a list of li’s to their parrent UL then you can interate those in code by pulling a list of li’s by the UL key that the li’s are hashed to.
A Map of lists if you will. So Map.get(“ulKey”) returns a list of li’s you can now iterate and run appropriate code on. Make sense?