473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

<% ... %> constructs?

I'm getting a parser error message:
Server tags cannot contain <% ... %> constructs...

Ok.. so How do I accomplish this:

For Each file in Files
if ucase(right(file.name,7))<>ucase("_tn.jpg") and
ucase(right(file.name,4))=ucase(".jpg") then
tnName=left(file.name,len(file.name)-4) & "_tn.jpg"%>
<asp:imagebutton runat="server" ImageUrl=<%=tnName%> onClick="IB_Click"/>

Thx,
MS
Nov 18 '05 #1
1 1914
That's correct. Remember, in ASP that worked because you were just
processing script in a page. In ASP.Net this doesn't work as well because
it's evaluating controls and events at once. You can't dynamically
response.write code into a control like this since they are both being
evaluated at the same time and it can't know which to evaluate first, the
response.write that you're dumping into the ImageUrl of the control itself.
It's tricky getting out of the ASP way of doing things but since this is
truly object-oriented now you can access the properties of this
programatically. Assign an id to the imagebutton (such as <asp:imagebutton
id="myButton"..... then you can just call the code myButton.ImageUrl =
tnName.

Of course, if you're doing a loop this isn't going to work. You'll need to
use another construct of some sort, such as a table where you can create
rows, create a new imagebutton programatically, then add it to the table row
before adding it to the cell like so:

<asp:table runat="server" id="myTable" />

Then in code behind or in the aspx page itself you can put this code into
the Page_Load event or another appropriate event. (the code sample below is
in C#, but should translate easily into VB)

// insert your loop code For Each then the following
TableRow trRow = new TableRow();
TableCell tcCell = new TableCell();
ImageButton myImage = new ImageButton();
myImage.ImageUrl = tnName;
myImage.Click += new ImageClickEventHandler(IB_Click);
tcCell.Controls.Add(myImage);
trRow.Cells.Add(tcCell);
myTable.Rows.Add(myTable);
Hope this helps,
Mark Fitzpatrick
Microsoft MVP -FrontPage

"Martin Schmid" <ma**********@sbcglobal.net.nospam> wrote in message
news:uw**************@TK2MSFTNGP10.phx.gbl...
I'm getting a parser error message:
Server tags cannot contain <% ... %> constructs...

Ok.. so How do I accomplish this:

For Each file in Files
if ucase(right(file.name,7))<>ucase("_tn.jpg") and
ucase(right(file.name,4))=ucase(".jpg") then
tnName=left(file.name,len(file.name)-4) & "_tn.jpg"%>
<asp:imagebutton runat="server" ImageUrl=<%=tnName%> onClick="IB_Click"/>
Thx,
MS

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John Tiger | last post by:
Can anybody have idea about the difference between #include <iostream.h> and #include <iostream>. Is later one valid statement on any compiler. I tried compiling on MSVC second statement give...
1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
2
by: AES/newspost | last post by:
In a markup like <dd> <br> some other stuff <br> </dd> the first break seems to add a blank line before the other stuff, but the second doesn't add a blank line after the other stuff. The...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
14
by: laurence | last post by:
I am implementing a comprehensive image-map generator utility, so have been studying W3C HTML 4.01 Specification (http://www.w3.org/TR/html4/struct/objects.html#h-13.6) on image maps (among other...
4
by: Neil Zanella | last post by:
Hello, I would like to know what the difference is among the constructs <%= %> for evaluating an expression and displaying the evaluated result on the page and <%# %>. In particular I would like...
14
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
11
by: Holger | last post by:
Hi I have not been able to figure out how to do compound statement from C - "<test>?<true-val>:<false-val>" But something similar must exist...?! I would like to do the equivalent if python...
10
by: Summercoolness | last post by:
so i am starting to use more of <br /and <div style="clear: both" / which is the XHTML style... now, won't those actually confuse the old browsers? for example, will the old browser treat the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.