Jimmy
|
| Posted: 02/05/2006, 4:32 AM |
|
I've been toying with the code grabbed from http://forums.yessoftware.com/posts.php?post_id=70048 (hope it is OK)
but can not get it to work. I set up a grid called "books" have a field in it called "picture" and want it to replace one pic with another if it is not found on the FS. Keep getting a error
Microsoft VBScript runtime error '800a01f4'
Variable is undefined: 'books'
(points to the second line below)
--------
Dim filespec, FSO
filespec = books.picture.Value
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
If FSO.FileExists( Server.MapPath( filespec) ) Then
books.picture.Value = filespec
Else
books.picture.Value = "./images/books/no.jpg"
End If
--------
Any clues to why this does not work ?
|
|
|
 |
Jimmy
|
| Posted: 02/05/2006, 5:40 AM |
|
Twist in the tale,
It works just fine on a single page, but as soon as I make the page includable, and use the page within another, it fails.
Can you help please.....
|
|
|
 |
Saud
Posts: 15
|
| Posted: 02/05/2006, 9:51 AM |
|
Quote :It works just fine on a single page, but as soon as I make the page includable, and use the page within another, it fails.
I believe if you have an includable page, then all variables in that page must hold the includable page name when you use them in the events page.
For example, if your includable page is called (IncludablePage1) then and you have a component called (Component1) in this page you want to use in a Custom Code Event. Then, you should write the name of the component as the following:
IncludablePage1.Component1.Value
Another example would be when you have a Grid called (Grid1) which contains a component called (Component1) in an includable page called (IncludablePage1), then use the following:
IncludablePage1.Grid1.Component1.Value
I hope this helps.
Saud
|
 |
 |
Jimmy
|
| Posted: 02/05/2006, 10:19 AM |
|
Hi,
Thanks for that, but does not work.
Page is called: ads
Grid = books
item (type image) = picture
I have tried using these formats and all fail.
1. filespec = books.picture.Value
2. filespec = ads.books.picture.Value
3. filespec = ads.picture.Value
Any other ideas please?
|
|
|
 |
TheunisP
Posts: 342
|
| Posted: 02/05/2006, 12:54 PM |
|
ok, 2 things I've noticed
1. check the event name is normally gives you an indication of what the variable is called e.g. pagename.container.variable etc
2. if you use this code in an event e.g. beforeshow - then try using eventcaller.value
hope it helps
|
 |
 |
Jimmy
|
| Posted: 02/06/2006, 8:29 AM |
|
Nope....
Grrrrr cant get it going, anybody got a sample of one that works ?
Thanks
|
|
|
 |
TheunisP
Posts: 342
|
| Posted: 02/06/2006, 8:56 AM |
|
ok - just thought of something the moment you hit the 1st period on either ads or books (which ever one is currently in scope) you should get a drop down with all the valid options - also are you sure this piece of code is in the correct event?
|
 |
 |
|