locked
Adding Literals to Placeholder in a tabular format RRS feed

  • Question

  • User245475216 posted

    So, this is my situation. I have a label and an image. I am adding the label and image to the controls and then to placeholder from code behind. I see the below format is displayed. Is there a way, I can display both placeholders side by side ? The controls and placeholders are formed dynamically using for loop. 

    label

    Image

    label
    Image
    Thursday, November 29, 2018 5:14 PM

All replies

  • User475983607 posted

    So, this is my situation. I have a label and an image. I am adding the label and image to the controls and then to placeholder from code behind. I see the below format is displayed. Is there a way, I can display both placeholders side by side ? The controls and placeholders are formed dynamically using for loop. 

    label

    Image

    label
    Image

    Simply use one of the many bound server controls like a GridView or Repeater.

    https://msdn.microsoft.com/en-us/library/ms228214.aspx?f=255&MSPPError=-2147217396

    Thursday, November 29, 2018 6:12 PM
  • User-271186128 posted

    Hi prasadbvm

    Adding Literals to Placeholder in a tabular format

    You could try to add rows to Table dynamically, and populate the label and image control. More details, please refer to this link:

    Dynamically Adding Rows in ASP Table on Button Click event

    Best regards,
    Dillion

    Friday, November 30, 2018 5:47 AM
  • User61956409 posted

    Hi prasadbvm,

    I see the below format is displayed. Is there a way, I can display both placeholders side by side ?

    To display the dynamic content (label and image) side by side, you can try to add them to a Panel first, and specify CssClass for that Panel to control the displaying of the content.

    Panel pn1 = new Panel();
    pn1.CssClass = "items";
    
    Label lbl1 = new Label() { Text = "Content1" };
    Image img1 = new Image() { ImageUrl = "https://i.imgur.com/C7QdL2K.jpg" };
    
    pn1.Controls.Add(lbl1);
    pn1.Controls.Add(img1);
    
    //other code logic
    
    PlaceHolder1.Controls.Add(pn1);

    //other code logic

    CSS style:

    <style>
        .items {
            display: block;
            float: left;
            border: 5px solid #f8ecb1;
            margin-left: 5px;
        }
    </style>

    Test Result:

    With Regards,

    Fei Han

    Thursday, December 6, 2018 9:25 AM