I have this problem: From a database, held up a string, which contains HTML mixed with C# code. I wish I could run correctly both codes on my page .aspx.
e.g. in my .aspx:
<div><%= Model.repo.getCode() %></div>
and the getCode() method give me this:
<div id="secondDiv"><p><%= Model.Person.Name %></p></div>
so I want the final html file look like:
<div><div id="secondDiv"><p>Jhon</p></div></div>
any suggestion?
C Expression Evaluation In the C programming language, an expression is evaluated based on the operator precedence and associativity. When there are multiple operators in an expression, they are evaluated according to their precedence and associativity.
Expression evaluation in C is used to determine the order of the operators to calculate the accurate output. Arithmetic, Relational, Logical, and Conditional are expression evaluations in C.
There is no concept of left-to-right or right-to-left evaluation in C, which is not to be confused with left-to-right and right-to-left associativity of operators: the expression f1() + f2() + f3() is parsed as (f1() + f2()) + f3() due to left-to-right associativity of operator+, but the function call to f3 may be ...
In C language '%' is known as modulus operator. It is used to find remainder. e.g- 15%2=1. In the above example when we divide 15 by 2 the remainder will be 1. Hence by using '%' operator we can find the remainder.
There may be direct way to bind such value, But if you could store String.Formatable into database then it would be easy to bind the data needed.
Using String.Format you achieve like,
returned string from Model.repo.getCode() (see curly braces)
"<div id="secondDiv"><p>{0}</p></div>";
And in ASP code,
<div><%= string.format(Model.repo.getCode(),Model.Person.Name) %></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With