Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Replace markup with real code

Reply
Thread Tools

Replace markup with real code

 
 
bateman
Guest
Posts: n/a
 
      11-22-2004
Hi, what I am trying to do is the following, its causing some probs though:

I have the following in a database:
[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

And want to change it to:
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
height="200" /><br />
This is the description text</div>
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

In the future I might want to use different codes ie [[imagediv 100.jpg This
is the description text]] to reference a different DIV.

Any ideas?


 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      11-22-2004
Can't say that I follow. What's in the database now? The entire literal
string from "[[imagediv..." to "placeholding use only."? All in one column?
What is the purpose of this data? What are you trying to acheive here?

Ray at work

"bateman" <> wrote in message
news:...
> Hi, what I am trying to do is the following, its causing some probs
> though:
>
> I have the following in a database:
> [[imagediv 100.jpg This is the description text]]
> This is just some dummy text. It doesn't mean anything and is for
> placeholding use only.
>
> And want to change it to:
> <div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
> height="200" /><br />
> This is the description text</div>
> This is just some dummy text. It doesn't mean anything and is for
> placeholding use only.
>
> In the future I might want to use different codes ie [[imagediv 100.jpg
> This is the description text]] to reference a different DIV.
>
> Any ideas?
>



 
Reply With Quote
 
 
 
 
bateman
Guest
Posts: n/a
 
      11-22-2004
Hi, sorry about that.
Yeah if I return the field from the database I get:

[[imagediv 100.jpg This is the description text]]
This is just some dummy text. It doesn't mean anything and is for
placeholding use only.

The reason for this is that I am trying to write a system for a user to
easily add a article, the bits in [[ ]] will be created by buttons they
press making it hopefully pretty much foolproof. I don't trust them with
real code!

There could be multiple instances of this in the field so what I was hoping
I could do was something like this (written in non-code code!)

Take the returned field
Go through it
if you find [[ take out the text between [[ and ]]
split into 3 parts, the first word (imagediv in this case), the picture name
(100.jpg) and the description text (This is the description text)
Then replace the [[ ...... ]] with
<div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
height="200" /><br />This is the description text</div>

Then I can use the modified string in my code, hopefully showing the picture
without ever having to explain what a DIV is!



"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:...
> Can't say that I follow. What's in the database now? The entire literal
> string from "[[imagediv..." to "placeholding use only."? All in one
> column? What is the purpose of this data? What are you trying to acheive
> here?
>
> Ray at work
>
> "bateman" <> wrote in message
> news:...
>> Hi, what I am trying to do is the following, its causing some probs
>> though:
>>
>> I have the following in a database:
>> [[imagediv 100.jpg This is the description text]]
>> This is just some dummy text. It doesn't mean anything and is for
>> placeholding use only.
>>
>> And want to change it to:
>> <div class="imagediv"><img src="/images/100.jpg" alt="100.jpg"
>> width="200" height="200" /><br />
>> This is the description text</div>
>> This is just some dummy text. It doesn't mean anything and is for
>> placeholding use only.
>>
>> In the future I might want to use different codes ie [[imagediv 100.jpg
>> This is the description text]] to reference a different DIV.
>>
>> Any ideas?
>>

>
>



 
Reply With Quote
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      11-23-2004
If the end user doesn't see [[imagediv 100.jpg This is the description
text]] then why not, when they click the button, just create the whole code?

Store <img scr=100.jpg alt='This is the description text'> etc...

Why build two steps to creating HTML? It's HTML, not hyroglyphics...

--
http://www.aspfaq.com/
(Reverse address to reply.)




"bateman" <> wrote in message
news:...
> Hi, sorry about that.
> Yeah if I return the field from the database I get:
>
> [[imagediv 100.jpg This is the description text]]
> This is just some dummy text. It doesn't mean anything and is for
> placeholding use only.
>
> The reason for this is that I am trying to write a system for a user to
> easily add a article, the bits in [[ ]] will be created by buttons they
> press making it hopefully pretty much foolproof. I don't trust them with
> real code!
>
> There could be multiple instances of this in the field so what I was

hoping
> I could do was something like this (written in non-code code!)
>
> Take the returned field
> Go through it
> if you find [[ take out the text between [[ and ]]
> split into 3 parts, the first word (imagediv in this case), the picture

name
> (100.jpg) and the description text (This is the description text)
> Then replace the [[ ...... ]] with
> <div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
> height="200" /><br />This is the description text</div>
>
> Then I can use the modified string in my code, hopefully showing the

picture
> without ever having to explain what a DIV is!
>
>
>
> "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
> message news:...
> > Can't say that I follow. What's in the database now? The entire

literal
> > string from "[[imagediv..." to "placeholding use only."? All in one
> > column? What is the purpose of this data? What are you trying to

acheive
> > here?
> >
> > Ray at work
> >
> > "bateman" <> wrote in message
> > news:...
> >> Hi, what I am trying to do is the following, its causing some probs
> >> though:
> >>
> >> I have the following in a database:
> >> [[imagediv 100.jpg This is the description text]]
> >> This is just some dummy text. It doesn't mean anything and is for
> >> placeholding use only.
> >>
> >> And want to change it to:
> >> <div class="imagediv"><img src="/images/100.jpg" alt="100.jpg"
> >> width="200" height="200" /><br />
> >> This is the description text</div>
> >> This is just some dummy text. It doesn't mean anything and is for
> >> placeholding use only.
> >>
> >> In the future I might want to use different codes ie [[imagediv 100.jpg
> >> This is the description text]] to reference a different DIV.
> >>
> >> Any ideas?
> >>

> >
> >

>
>



 
Reply With Quote
 
Bob Lehmann
Guest
Posts: n/a
 
      11-23-2004
Why don't you keep the image name and description in seperate columns in the
DB?

Why does the user have to know anything about <div>? Can't you just output
that in the code?

Why are you are making it so hard on yourself with contrived data formats?


Bob Lehmann

"bateman" <> wrote in message
news:...
> Hi, sorry about that.
> Yeah if I return the field from the database I get:
>
> [[imagediv 100.jpg This is the description text]]
> This is just some dummy text. It doesn't mean anything and is for
> placeholding use only.
>
> The reason for this is that I am trying to write a system for a user to
> easily add a article, the bits in [[ ]] will be created by buttons they
> press making it hopefully pretty much foolproof. I don't trust them with
> real code!
>
> There could be multiple instances of this in the field so what I was

hoping
> I could do was something like this (written in non-code code!)
>
> Take the returned field
> Go through it
> if you find [[ take out the text between [[ and ]]
> split into 3 parts, the first word (imagediv in this case), the picture

name
> (100.jpg) and the description text (This is the description text)
> Then replace the [[ ...... ]] with
> <div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
> height="200" /><br />This is the description text</div>
>
> Then I can use the modified string in my code, hopefully showing the

picture
> without ever having to explain what a DIV is!
>
>
>
> "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
> message news:...
> > Can't say that I follow. What's in the database now? The entire

literal
> > string from "[[imagediv..." to "placeholding use only."? All in one
> > column? What is the purpose of this data? What are you trying to

acheive
> > here?
> >
> > Ray at work
> >
> > "bateman" <> wrote in message
> > news:...
> >> Hi, what I am trying to do is the following, its causing some probs
> >> though:
> >>
> >> I have the following in a database:
> >> [[imagediv 100.jpg This is the description text]]
> >> This is just some dummy text. It doesn't mean anything and is for
> >> placeholding use only.
> >>
> >> And want to change it to:
> >> <div class="imagediv"><img src="/images/100.jpg" alt="100.jpg"
> >> width="200" height="200" /><br />
> >> This is the description text</div>
> >> This is just some dummy text. It doesn't mean anything and is for
> >> placeholding use only.
> >>
> >> In the future I might want to use different codes ie [[imagediv 100.jpg
> >> This is the description text]] to reference a different DIV.
> >>
> >> Any ideas?
> >>

> >
> >

>
>



 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      11-23-2004
bateman wrote on 23 nov 2004 in microsoft.public.inetserver.asp.general:

> [[imagediv 100.jpg This is the description text]]


> <div class="imagediv"><img src="/images/100.jpg" alt="100.jpg"
> width="200" height="200" /><br />This is the description text</div>


it is simple string manipulation.

Using vbscript:

================================

s = "[[imagediv 100.jpg This is the description text]]"

s= replace(s,"[[","")
s= replace(s,"]]","")

a = split(s," ")

r = "<div class='" & a(0) & "'>"

r = r & "<img src='/images/" & a(1) & "' alt='" & a(1)

r = r & "' width='200' height='200' /><br />"

for i=2 to ubound(a)
r = r & a(i) & " "
next

result = left(r,len(r)-1) & "</div>"

================

Instring HTML quotes are replaced with single ones.

I would put the width and height in the css clas description



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

 
Reply With Quote
 
Jeff Cochran
Guest
Posts: n/a
 
      11-23-2004
On Mon, 22 Nov 2004 23:01:04 -0000, "bateman"
<> wrote:

>Hi, what I am trying to do is the following, its causing some probs though:
>
>I have the following in a database:
>[[imagediv 100.jpg This is the description text]]
>This is just some dummy text. It doesn't mean anything and is for
>placeholding use only.
>
>And want to change it to:
><div class="imagediv"><img src="/images/100.jpg" alt="100.jpg" width="200"
>height="200" /><br />
>This is the description text</div>
>This is just some dummy text. It doesn't mean anything and is for
>placeholding use only.
>
>In the future I might want to use different codes ie [[imagediv 100.jpg This
>is the description text]] to reference a different DIV.
>
>Any ideas?


First idea is to stop trying to do this. Keep data in the database,
markup in your page language. Second is to learn to use a database.
The image file name is an attribute. The image description is an
attribute. Attributes define your columns. So you should have:

ImageNumber - An autoassigned number to use as a unique key
ImageFileName - The actual file name (possibly with path, or a
separate column for path)
ImageDescription - The descriptive text about the image.

Retrieve the image file name from your database, display that file
along with the description.

And until the user places the data in the database, you don't need a
place holder. Don't create the record.

Jeff
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
AsyncPostBackTrigger not resolving in markup code. =?Utf-8?B?TWljaGFlbCBkZSBWZXJh?= ASP .Net 0 03-15-2007 06:09 PM
Seperating code from HTML markup =?Utf-8?B?Sm9l?= ASP .Net 2 02-15-2006 03:29 PM
Math markup in code documentation? schwehr@gmail.com Python 3 10-25-2005 03:38 PM
Add markup code to specific words in a text Toska ASP .Net 0 01-31-2005 01:48 PM
Add markup code to specific words in a text Toska ASP .Net 1 01-30-2005 10:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57