1

In my program I have the following in my Site.Master

<div id="programs" runat="server">

and the following c#

programs.InnerHtml += $"<div style=\"width:80px; height:50px; align:center;\">{reader[1]}</div>";

Basically I have currently 2 programs listed in my db. I want to list each one side by side and any subsequent ones I may add in the future. when I use the += I get an error

Cannot get inner content of programs because the contents are not literal.

when I remove it gives me only the last record (which is expected).

Any ideas why I'm getting this error and what I can do to resolve it?

1 Answer 1

1

You have to use Controls.Add() try use this code

var x =$"<div style=\"width:80px; height:50px; align:center;\">{reader[1]}</div>";

programs.Controls.Add(new LiteralControl(x));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.