c# - Dynamically created panels not responding to CSS for alignment -


i working on website act blog. issue comments section , deals alignment of child comment panels. try add css float panels right, stay on left. have tried setting horizontalalign of parent panels right.

for more context, image of comments section:

as can see, child comments panels sticking left.

this method dynamically creating comments section exiting panel called panel1.

protected void drawcomments(string id, int numtabs, panel parentpanel) {         string hash = id;          sqlconnection conn = new sqlconnection(secret stuff);         string cmdstr = "select * comments parentid=@searchhash";         sqlcommand cmd = new sqlcommand(cmdstr, conn);         cmd.parameters.add("@searchhash", sqldbtype.nvarchar).value = hash;          try         {             conn.open();              sqldatareader reader = cmd.executereader();             panel temppanel;             if (reader.hasrows)             {                 while (reader.read())                 {                     id = reader.getstring(4);                     temppanel = new panel();                     temppanel.borderstyle = borderstyle.solid;                     temppanel.bordercolor = system.drawing.colortranslator.fromhtml("#2461bf");                     temppanel.width = new unit((100 - (numtabs * 5)).tostring() + "%");                     temppanel.attributes.add("style", "margin-left:auto;");                     temppanel.attributes.add("style", "margin-right:auto;");                       if (numtabs > 0)                     {                         temppanel.attributes.add("style", "margin-bottom:5px");                         //   temppanel.attributes.add("style", "border-top-style:none");                         temppanel.attributes.add("style", "border-left-style:none");                         // temppanel.attributes.add("style", "border-right-style:solid");                         temppanel.attributes.add("style", "border-bottom-style:none");                     }                     else                     {                         temppanel.attributes.add("style", "margin-top:50px");                        // panel1.controls.add(new literalcontrol("<br />"));                     }                     label currcomment = new label();                     label currauthor = new label();                     currcomment.text = reader.getstring(0);                     currauthor.text = reader.getstring(3).split('@')[0];                       table tbl = new table();                     tbl.width = new unit("100%");                     tbl.attributes.add("style", "margin-left:auto");                     tbl.attributes.add("style", "margin-right:auto");                      tablerow tblrow1 = new tablerow();                      tablecell tblcell11 = new tablecell();                     tablecell tblcell12 = new tablecell();                      tblcell11.horizontalalign = horizontalalign.right;                     tblcell11.width = new unit("30%");                     tblcell11.text = currauthor.text + " says:";                      tblcell12.horizontalalign = horizontalalign.left;                     tblcell12.text = currcomment.text;                     tblcell12.width = new unit("70%");                      tblrow1.cells.add(tblcell11);                     tblrow1.cells.add(tblcell12);                     tbl.rows.add(tblrow1);                      tablecell tblcell21 = new tablecell();                     tblcell21.width = new unit("30%");                      imagebutton replybutton = new imagebutton();                     replybutton.imageurl = "~/images/replybutton.png";                     replybutton.attributes.add("style", "float:right");                     replybutton.width = 77;                     replybutton.id = id;                     replybutton.command += addreply;                      imagebutton likebutton = new imagebutton();                     likebutton.imageurl = "~/images/likebutton.png";                     likebutton.attributes.add("style", "float:right");                     likebutton.width = 65;                      label likecount = new label();                     likecount.attributes.add("style", "float:right");                     likecount.borderstyle = borderstyle.groove;                     likecount.text = "0";                      tablecell tblcell22 = new tablecell();                     tblcell22.horizontalalign = horizontalalign.left;                     tblcell22.controls.add(likecount);                     tblcell22.controls.add(likebutton);                     tblcell22.controls.add(replybutton);                     tblcell22.width = new unit("70%");                      tablerow tblrow2 = new tablerow();                     tblrow2.cells.add(tblcell21);                     tblrow2.cells.add(tblcell22);                      tbl.rows.add(tblrow2);                      temppanel.controls.add(tbl);                     //temppanel.controls.add(currcomment);                      if (numtabs>0)                     {                          parentpanel.controls.add(temppanel);                     }                     else                         panel1.controls.add(temppanel);                        drawcomments(reader.getstring(4), numtabs + 1, temppanel);                  }             }         }         catch (exception ex)         {             lbldebug.text = ex.tostring();         }         { conn.close(); }     } 

any suggestions these child panels right aligning appreciated. hope can understand going through poorly written code 15 year old.


Comments

Popular posts from this blog

Ansible warning on jinja2 braces on when -

Parsing a protocol message from Go by Java -

node.js - Node js - Trying to send POST request, but it is not loading javascript content -