response write within response write

0

I have a site in database (writes the page code inside the table), example:

<html>
...

This code above I saved in a field inside the table, and to display, I do it normally and everything comes right, however I need the following:

Inside the code has for example h1 date() h1 (I took because here it is understood as title

Summary:

When I do <%=%> is the same as response.write, then how do I put this variable inside the code that is already in the database?

I've tried everything when it's done and everything I put is printed on the screen exactly as I put it, in the example above, it's written on the page exactly that, date () inside h1.

detailed ..

I created a database inside another domain that I have and in it I created a table with longtext field and inside it I created the following:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> Login</title>

<body class="gray-bg">
<div><h1 class="logo-name"></h1></div>
<%=date()%> (aqui é onde já testei de tudo (risos)
</body>
</html>
... (página não esta completa, mas só foi para entender)

and within the domain I want the page I created the following:

SQLLerDados = "select * FROM sisindex"
Set RSLerDados=Server.CreateObject("ADODB.Recordset")
RSLerDados.Open SQLLerDados, objConnPagina

if RSLerDados.eof then
    response.End()
else
    codigoPagina = RSLerDados("codigoPagina")
    response.write codigoPagina
end if
Set RSLerDados = Nothing
response.End()

That is, it goes into my database and takes the page to be displayed, except that this page is in ASP and has commands and functions in it and the response.write is understood as independent text of how I put the ASP variables , understood? or think I did not explain right. Thanks

    
asked by anonymous 17.08.2016 / 01:06

2 answers

4

If it's in the HTML body:

<h1><%= date() %></h1>

If you are concatenating strings :

Response.Write "<h1>" & date() & "</h1>"

If your source code is stored with functions in the DB, it is the case to rethink the application urgently. This is usually not justified.

One solution would be a mini template system:

Entrada = "<h1>$DATA$</h1>"  'os dados teriam que estar assim no DB
Saida = Replace( Entrada, "$DATA$", date() )
Response.Write Saida
    
17.08.2016 / 01:46
-1

Ronaldo, unfortunately this thing you want to do is not possible, at least not directly so. Everything you put inside the Response.Write will be displayed as text. What is in html tag format will be interpreted by the browser as html because it reads the page in the client itself. ASP is processed by the server and when you give a Response.Write or a <% =% > it displays the result of ASP processing in text format for the browser to be able to interpret normally.

Now, I do not understand much the need to store the pages in bank. Can not save them as .asp same?

    
18.10.2016 / 23:27