Placing HTML inside ASP script

Discussion in 'C#' started by high1, Mar 17, 2010.

  1. #1
    Hello

    I have a simple ASP counter script which digits in text format:

    <%@ Language = VBSCRIPT %><% Option Explicit %><% ' Variable Section    Const ForReading = 1    Const ForWriting = 2    Const UseText = 0           ' Use this constant if you want to use text for the counter display    Const UseImages = 1         ' Use this constant if you want to use images for the counter display    Dim objCounterFile, objFSO, strFilePath, strImageName, displayOption, imageDirectory    Dim strCounterNumber, iCounterNumber, strCurrentIP, strLastIP' Set this equal either to 0 or 1, make it equal either UseImages of UseText' depending on which you want to use to show your counter.    displayOption = 0           ' Set this string equal to the sub-directories that you follow to your images directory' This is from the directory that contains the file that executes "counter.asp"    imageDirectory = "images/"          '' Gathering information    strCurrentIP = Request.ServerVariables("REMOTE_ADDR")    strFilePath = Server.MapPath("counter.txt")    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")'' Checking for the file counter.txt    If (objFSO.FileExists(strFilePath)) then      Set objCounterFile = objFSO.OpenTextFile(strFilePath, ForReading)' Reading the information in from the text file      iCounterNumber = Cdbl(objCounterFile.ReadLine) + 1      strLastIP = Cstr(objCounterFile.ReadLine)      objCounterFile.Close    Else ' If the doesn't exist start counting at 1      iCounterNumber = 1    End If'' If the current visitor's IP is different from the last visitor's IP then log the new information    If (strLastIP <> strCurrentIP) then      Set objCounterFile = objFSO.CreateTextFile(strFilePath, True)      objCounterFile.WriteLine(iCounterNumber)      objCounterFile.WriteLine(strCurrentIP)      objCounterFile.Close    Else       iCounterNumber = iCounterNumber - 1    End If'' Destroying the Objects    Set objCounterFile = Nothing    Set objFSO = Nothing''  Setting up the number to be displayed'  This setup allows for later changing to images from text    strCounterNumber = CStr(iCounterNumber)    While (Len(strCounterNumber) > 0)      strImageName = Left(strCounterNumber, 1)      If (displayOption = UseText) then        Response.Write (strImageName)      Elseif (displayOption = UseImages) then        Response.Write ("<IMG SRC=""" & imageDirectory & strImageName & ".gif"" BORDER=0>")      End If      strCounterNumber = Mid(strCounterNumber, 2)    Wend%>
    Code (markup):
    The output is simple Times Roman at about 10/12pt.

    How (or where) would I begin to format the output - to a differrnt font, say, or size, or maybe include it in a small box with a border?

    Many thanks for any ideas.

    High1
     
    high1, Mar 17, 2010 IP
  2. jonmaster

    jonmaster Peon

    Messages:
    181
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I am not sure which is the variable to display the counter data from your code. But it is easy to display as per your requirement.

    u can use the following code

    <div style="height:50px; width:100px; border: #993300 solid 1px; font-family: 'Times New Roman', Times, serif; font-size:12px;">
    <%
    Response.Write(strCounterText)
    %>
    </div>

    Where strCounterText is the variable to hold the counter values.
     
    jonmaster, Mar 17, 2010 IP
  3. www.petermoss.com

    www.petermoss.com Guest

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you can add "border-style: dashed", other border styles:

    none Specifies no border
    hidden The same as "none", except in border conflict resolution for table elements
    dotted Specifies a dotted border
    dashed Specifies a dashed border
    solid Specifies a solid border
    double Specifies a double border
    groove Specifies a 3D grooved border. The effect depends on the border-color value
    ridge Specifies a 3D ridged border. The effect depends on the border-color value
    inset Specifies a 3D inset border. The effect depends on the border-color value
    outset Specifies a 3D outset border. The effect depends on the border-color value
    inherit Specifies that the border style should be inherited from the parent element
     
    www.petermoss.com, Mar 17, 2010 IP
  4. high1

    high1 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello

    Many thanks to you both for your posts.

    I have resolved the query I had, so the page now looks like this:

    http://proofreading4students.com/my_counter.asp

    The colouring and size of that number is only a sample - I was just testing it. How, now, would I go about putting a little box around it? I would probably prefer a thin solid border of whatever colour.

    This is what I have in the code now:

    %>
    <span style="font-family: arial; font-size: 16pt; font-weight: bold; color: #333399;"><%=iCounterNumber%></span>
    <%
    
    Code (markup):
    Thanks again for your help.

    High1
     
    high1, Mar 19, 2010 IP
  5. john.michael.kane.kane

    john.michael.kane.kane Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Response.Write ("<IMG SRC='" & imageDirectory & strImageName & ".gif' BORDER=0>")
     
    john.michael.kane.kane, Mar 21, 2010 IP
  6. high1

    high1 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hello John

    That's great and many thanks for your help and sorry for the late reply.

    High1
     
    high1, Mar 26, 2010 IP