im trying to do somthing and got into a problem.
i got a function that adding html elements and thire attributes. now, i want to get the controls in server side (code behind) so i can do some stuff with them.
my problem is: i cant "find" them.
this is part of the function im using to add them, its a bit longer so i show only the controls i want to get in the server side:
public string EditPhoto(int x)
{
using (StringWriter stringWriter = new StringWriter())
{
using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
{
// Some strings for the attributes.
string classValue = "thumb";
//Begin #5 <div class=image-title">
writer.AddAttribute(HtmlTextWriterAttribute.Class, "image-title");
writer.AddAttribute("runat", "server"); //--> server side att
writer.AddAttribute(HtmlTextWriterAttribute.Id, "title" + x);
writer.RenderBeginTag(HtmlTextWriterTag.Input);
TextWriter innerTextWriter = writer.InnerWriter;
innerTextWriter.Write(title);
writer.RenderEndTag(); //#End 5 </div>
//Begin #6 <div class="image-desc">
writer.AddAttribute(HtmlTextWriterAttribute.Class, "image-desc");
writer.AddAttribute("runat", "server"); //--> server side att
writer.AddAttribute(HtmlTextWriterAttribute.Id, "desc" + x);
writer.RenderBeginTag(HtmlTextWriterTag.Input);
innerTextWriter = writer.InnerWriter;
innerTextWriter.Write(descreption);
writer.RenderEndTag(); //#End 6 </div>
writer.RenderEndTag();//#End 4 </div>
writer.RenderEndTag(); // End #1 </li>
}
// Return the result.
return stringWriter.ToString();
}
afther the function is done i got this Test code to try and look for them:
for (int i = 0; i < Controls.Count; i++)
{
if (FindControl("title" + i) != null)
Response.Write("Found 1 title control");
else
Response.Write( i +"There is no control");
}
for (int i = 0; i < Controls.Count; i++)
{
if (FindControl("desc" + i) != null)
Response.Write("Found 1 descreption control");
else
Response.Write(i + "Thre is no control");
}
sorry for my english