Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML & ASP in an Access Data Cell - HOW? 2

Status
Not open for further replies.

wniatbms

Programmer
Dec 5, 2003
24
0
0
ZA
Good day

I have a few pages on my site that will extract their text content from a table in my Access DBase. The problem I'm having is that when I view the page in a browser, it does not show asp. Eg.: The title of this page is <%=objRS("pageTitle")%>, with ID <%=objRS("ID_webPage").

The browser will display: "The title of this page is , with ID ."

But it does recognise html formatting: <b>,<br>, etc.

What am I doing wrong?

Thanks.
 
ASP code is parsed and executed by the server BEFORE the page is sent to the browser.
You are trying to run code after this point.



Chris.

Indifference will be the downfall of mankind, but who cares?
 
Thank you ChrisHirst.

Is there any workaround for this or is it just not possible to do at all?

Thank you for your time.
 
I usually put markup code into the db fields and then have a function to run a replace on the markup (forum style)

so the db text would be "The title is [title] with ID of [id]"

and a replace function would be

Code:
function textreplace(strText)
strText = replace("[title]",objRS("page_title"))
strText = replace("[id]",objRS("ID_webPage"))
textreplace = strText
end function




Chris.

Indifference will be the downfall of mankind, but who cares?
 
You could use the Execute method to execute the ASP code in the field, but I warn you this is very very very very very (get the idea?) dangerous. If I wanted to take down or hack your site this would allow me to do it in no time flat because all I would have to do is get an entry into a form that had some scripts to, i dunno, add a user acount to the server and your script would just run it, never knowing it was opening the server up to me to access with a seemingly legitimate account.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
ChrisHirst:

Thank you so much for that code. It will be most helpful.

Tarwn:

Thank you for that warning.

Please excuse my lack of knowledge here - I am very new to all of this - but what are you refering to when you say "the Execute method"? It wouldn't be the code ChrisHirst has supplied, would it?

Thank you all.
 
Nope, there is an actual Execute() method that will take a string you provide it and execute it as if it were ASP code on the line. Example:
Code:
<%
Dim aString
aString = "Response.Write ""Some text being written from an executed string"""
Execute(aString)
%>

Basically you could fill that string from any source you want, it will then take the string and execute it as an ASP instruction.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top