Results 1 to 2 of 2

Thread: Option Explicit

  1. #1
    Contributing Member
    Join Date
    May 2006
    Answers
    82

    Option Explicit

    What is the reason for using Option Explicit in ASP? In other words I want to know the usage of Option Explicit in ASP.


  2. #2
    Junior Member
    Join Date
    Jul 2006
    Answers
    4

    Re: Option Explicit

    Quote Originally Posted by timmy
    What is the reason for using Option Explicit in ASP? In other words I want to know the usage of Option Explicit in ASP.
    Hi
    The Importance of Option Explicit in ASP is to avoid the usage of misSpelling variables .
    For ex:
    <%
    sEmpID = request.form("TxtEmpID")
    sEmpName = request.form("TxtEmpName")

    response.write "Login ID : "&sEmpId &" Login Name "&sEpName
    %>

    Notice the misSpelling of sEmpName ,bcoz server automatically create a new variable (sEpName) with blank string and since we have not used Option Explicit , this error goes un-noticed.

    When u use Option Explicit it must be the first line of ASP Script
    <%
    Option Explicit
    dim sEmpId,sEmpName

    sEmpID = request.form("TxtEmpID")
    sEmpName = request.form("TxtEmpName")

    response.write "Login ID : "&sEmpId &" Login Name "&sEpName
    %>

    In this case u got an Error like Variable is Undefined : sEpName.

    This let's us know exactly where the error is, so we can go straight to the problem and fix it.

    Santhi


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact