Tech Off Thread

4 posts

Object Expected Error

Back to Forum: Tech Off
  • User profile image
    SLTDon

    As you can probably tell I am new to ASP.NET so please bear with me.  I am getting an "Object Expected" error on the INPUT type = "text" on line 179 and 183 and I can't fingure out why.  Can someone point me in the right direction.

    Thanks,

    SLTDon

    <%@ Page Language="VB" EnableSessionState="True" debug="true"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

    Dim lUpdateMode As Boolean

    Dim LastModified As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    lastmodified = System.IO.File.GetLastWriteTime(Server.MapPath(Request.ServerVariables("SCRIPT_NAME")))

    lUpdateMode = False

    If Page.IsPostBack Then

    'Select Case Request.QueryString("B1")

    'Case "Add"

    'Case "Update"

    'Case "Delete"

    'Case "Cancel"

    'End Select

    End If

    End Sub

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head >

    <title>User Type Maintenance</title>

    <link rel="stylesheet" type="text/css" href="CPM.css" />

    <script language="vbscript" type="text/VB">

    function Validate()

    dim lAnyError

    lAnyError = false

    end function

    sub SetFocus(s)

    set obj = window.event.srcElement

    obj.className = s

    set obj = Nothing

    end sub

    function SetShow()

    set e = window.event.srcElement

    if e.className = "error" then

    if not isNull(e.GetAttribute("ERRORNUM")) then

    e.errornum = ""

    end if

    end if

    if e.className = "error" then

    e.className = "ondata"

    end if

    if e.className = "indata" then

    e.className = "ondata"

    end if

    if ucase(e.type) = "TEXT" then

    if not isnull(e.GetAttribute("MASK")) then

    StripMask e

    end if

    end if

    if ucase(e.type) = "TEXT" then

    e.select()

    end if

    end function

    function DontShow()

    set e = window.event.srcElement

    if e.className = "ondata" then

    e.className = "indata"

    end if

    if ucase(e.type) = "TEXT" then

    if not isnull(e.getAttribute("MASK")) then

    StripMask e

    ShowMask e

    end if

    end if

    end function

    '--------------------------------------------------------------------

    ' Routine to strip Mask from input data.

    '--------------------------------------------------------------------

    sub StripMask(obj)

    dim wrk

    dim aTbl

    wrk = obj.value

    if trim(wrk) = "" then

    exit sub

    end if

    select case Ucase(obj.mask)

    case "SSN"

    wrk = replace(wrk,"-","")

    obj.value = wrk

    case "PHONE"

    wrk = replace(wrk,"(","")

    wrk = replace(wrk,")","")

    wrk = replace(wrk,"-","")

    wrk = replace(wrk," ","")

    obj.value = wrk

    case "ZIP"

    wrk = replace(wrk,"-","")

    obj.value = wrk

    case "DATE"

    if len(trim(wrk)) = 0 then

    exit sub

    end if

    wrk = replace(wrk,"-","/")

    atbl = split(wrk,"/")

    if ubound(aTbl) > 0 then

    if len(aTbl(0)) = 1 then

    aTbl(0) = "0" & aTbl(0)

    end if

    if len(aTbl(1)) = 1 then

    aTbl(1) = "0" & aTbl(1)

    end if

    wrk = aTbl(0) & "/" & aTbl(1) & "/" & aTbl(2)

    end if

    wrk = replace(wrk,"/","")

    obj.value = wrk

    end select

    end sub

    '--------------------------------------------------------------------

    ' Routine to insert Mask into input data.

    '--------------------------------------------------------------------

    sub ShowMask(obj)

    dim wrk

    dim mo

    dim dy

    dim yr

    wrk = obj.value

    if trim(wrk) = "" then

    exit sub

    end if

    select case ucase(obj.mask)

    case "SSN"

    wrk = left(wrk,3) & "-" & mid(wrk,4,2) & "-" & mid(wrk,6,4)

    obj.value = wrk

    case "PHONE"

    if trim(len(wrk)) = 7 then

    wrk = "530" & wrk

    end if

    wrk = "(" & left(wrk,3) & ") " & mid(wrk,4,3) & "-" & mid(wrk,7,4)

    obj.value = wrk

    case "ZIP"

    if len(wrk) = 5 then

    exit sub

    end if

    wrk = left(wrk,5) & "-" & mid(wrk,6,4)

    obj.value = wrk

    case "DATE"

    if len(wrk) < 6 then

    obj.className = "error"

    obj.title = "Improperly formatted date. Please correct."

    exit sub

    end if

    if len(wrk) > 6 then

    yr = right(wrk,4)

    wrk = left(wrk,len(wrk) - 4)

    else

    yr = right(wrk,2)

    wrk = left(wrk,len(wrk) - 2)

    end if

    mo = left(wrk,2)

    dy = right(wrk,2)

    wrk = mo & "/" & dy & "/" & yr

    obj.value = wrk

    end select

    end sub

    sub ShowHelp(Pg)

    set helpChild1 = window.open(Pg,"MyWindow1","toolbar=no,scrollbars=yes,top=10,left=10,resizable=yes")

    end sub

    </script>

    </head>

    <body class="background" onload="form1.TC.focus()">

    <form id="form1" name="form1" action="UserTypeBottom.aspx" onsubmit="return Validate()">

    <div>

    <table border="1" cellspacing="0" align="center">

    <tr>

    <td class="leftSide">Code:</td>

    <td class="rightSide"><input type="text" name="TC" size="2" maxlength="2" class="indata" onfocus="SetFocus()" onblur="DontShow()"/></td>

    </tr>

    <tr>

    <td class="leftSide">Description:</td>

    <td class="rightSide"><input type="text" name="Desc" size="30" maxlength="50" class="indata" onfocus="SetFocus()" onblur="DontShow()"/></td>

    </tr>

    <tr>

    <td colspan="2" align="center">

    <%If lUpdateMode Then%>

    <input type="button" value="Update" name="B1" onmouseout="SetFocus('button')" onmouseover="SetFocus('highlightButton')" onfocus="SetFocus('highlightbutton')" onblur="SetFocus('button')" />

    <input type="button" value="Delete" name="B1" onmouseout="SetFocus('button')" onmouseover="SetFocus('highlightButton')" onfocus="SetFocus('highlightbutton')" onblur="SetFocus('button')" />

    <%end if %>

    <%If Not lUpdateMode Then%>

    <input type="button" value="Add" name="B1" onmouseout="SetFocus('button')" onmouseover="SetFocus('highlightButton')" onfocus="SetFocus('highlightbutton')" onblur="SetFocus('button')" />

    <%end if %>

    <input type="button" value="Cancel" name="B1" onmouseout="SetFocus('button')" onmouseover="SetFocus('highlightButton')" onfocus="SetFocus('highlightbutton')" onblur="SetFocus('button')" />

    </td>

    </tr>

    </table>

    </div>

    </form>

    <p align="center"><button onclick="parent(0).location='userTypeTop.aspx'">Refresh User Type Grid</button>

    <button onclick="parent.location='StatusPage.aspx'">Status Page</button></p>

    <p class="copyRight">(c) 2006, Sirron Software Corporation, All Rights Reserved.<br />

    Page Last Modified: <%=LastModified%><br />

    Version: 1.00</p>

    </body>

    </html>

  • User profile image
    SLTDon

    This error was caused by the Type="text/VB" attribute in the <SCRIPT> element.  Its interesting that this was the error because without the Type atribute VS2005 was giving me an error.

    I have since turned off validation of HTML in VS2005.

    Thanks,

    SLTDon

  • User profile image
    Blue Ink

    As far as I know, the correct mime type for VBScript is "text/vbscript", not "text/vb".

    Also, VS complains at: onfocus="SetFocus()", since the sub expects a parameter.

    HTH
    --m

  • User profile image
    W3bbo

    Blue Ink wrote:

    As far as I know, the correct mime type for VBScript is "text/vbscript", not "text/vb".

    Also, VS complains at: onfocus="SetFocus()", since the sub expects a parameter.

    HTH
    --m



    Not forgetting that VBScript is only supported by IE.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.