I am trying to make a "repeater" type of webpage using an expanded template.
The page works OK in itself, but this:
<% SCAN %>
Name: <input id="txtName_<%= Tquery.Pk %>" name="txtName_<%= Tquery.Pk %>"
value="<%= TQuery.Name %>" />
<% ENDSCAN %>
Throws two errors.
Is this structure still possible?
George ...
Yes that should work assuming TQuery
is the active cursor and the field names are in the cursor.
I would make sure with:
<%
select TQuery
SCAN
%>
<% ENDSCAN %>
Note you might also want to make sure the text value is HTML Encoded so:
<input id="txtName_<%= Tquery.Pk %>"
name="txtName_<%= Tquery.Pk %>"
value="<%: TQuery.Name %>" />
Notice the <%: Tquery.Name %>
which HTML encodes the text to avoid scripting attacks and formatting errors for certain characters with your text input.
+++ Rick ---
Thanks Rick,
Still no joy. I pasted the code as you suggested, like this from VSCode window.
<%
select TQuery
SCAN
%>
<input id="txtName_<%= Tquery.Pk %>" name="txtName_<%= Tquery.Pk %>"
value="<%: TQuery.Name %>" />
<% ENDSCAN %>
This is what renders on the Web Page. My Cursor is in scope and the first name is the string as shown below.
< % ERROR: select TQuery SCAN % > 849514-13< % ERROR: ENDSCAN % >
Any ideas? PS am using 712, and get the same results on two machines now.
George
Hi Rick,
Quick update:
I installed the mainenance patch that you just released just now.
I recompiled everything inc. the classes and classlibs.
Still getting the error 😦
George ...
Rick,
please pardon me for jumping in.
I don't recall ever having seen the <%:
construct before, is that new? Also, I don't find it mentioned in the documentation.
No it's not new. It's been in there since 5.50 I think. We've talked about it in the Web Connection training a bunch. It's not a very high profile item and I realized today that it wasn't documented real well.
I added it here:
+++ Rick ---
With the code you have make sure you are using ExpandScript()
not ExpandTemplate()
.
Templates can't execute continuous code like a SCAN
loop between multiple code blocks. Scripts can because they compile down into PRG files that are executed.
Response.ExpandScript()
Read more here:
and here:
+++ Rick ---
You don't expect me to remember every little detail, do you? 😃
Oh yes I do!
There will be a quiz next week! 😄
+++ Rick ---
Challenge accepted! 😃