#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Australia
    Posts
    20
    Rep Power
    0

    Conditional Compilation


    One of my asp pages can be loaded in two ways - it may be submitted to itself (and therefore contains user data) or it can be loaded by clicking on a link on my menu, and consequently all fields are empty.

    If the fields contain values (ie. the submit button was pressed), i want to load data from my database into an array, but if it is accessed via a link, i don't want this data to be loaded.

    So essentially, i want to know if there is some form of conditional compilation or something in asp (i know it technically shouldn't be called that, but i'm coming from a c++ background, so...) similar to the #if and #elif type directives in C

    I can't place the code in a subprogram and selectively call it, because I want the arrays to be global so all my client-side scripts can access the data

    I'm using VBScript for the asp scripting. Any help here would be greatly appreciated.

    Comments on this post

    • JimmyGosling agrees
  2. #2
  3. No Profile Picture
    Techincal Developer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    New Delhi India
    Posts
    12
    Rep Power
    0

    plz calrify u'r Problem mam


    hi mam
    i m working in ASP in india from last 2+ yrs
    but it hard 2 understand u'r prob. after reading u'r thread(don't mind mam).
    but after reading u'r prob. i came to know
    u wanna display DB value on SUBMIT BUTTON and an blank values on a click of A LINK
    right mam
    so u can do thins by the use of just only a hidden button
    u have to make one hidden form element in u'r form and put its value to blank and on click on the SUBMIT BUTTON call one javascript function by the help of this function just assign some value to the hidden form element and submit the form to desired action.
    and on click of the LINK don't assign any value but submit the form on desired action.
    after form submision just chk the value of hidden fields if it contains value thn do one operation which u wanna and if hidden is blank thn do other operation u wanna
    i hope this will make sense to u
    else feel free to ask any thing again
    bye
    Sur

    Comments on this post

    • JimmyGosling agrees
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    138
    Rep Power
    12
    There are a few options available.

    There first is test if all fields are empty after submission if they are assume that the menu link was pressed. This does not allow you to determine if a blank form was submitted so I gues you have already thought of that.

    The next on the list is to put a hidden input in the form, something like this.

    <input type="hidden" name="wasform" value="true">

    now you can test
    If Request("wasform") = "true" Then
    ...
    Else
    ...
    End If

    But my choice would be to make sure your form is submitting with method="post" ie.
    <form action="myasp.asp" method="post" name="myForm">
    If your menu link is an <a href="myasp.asp"> tag or an onClick="location.href=myasp.asp" event as long as it doesn't do a myForm.submit() that is as long a http get you can use the following code.

    If Request.ServerVariable("REQUEST_METHOD") = "POST" Then
    ' my database code
    Else
    ' somebody selected page from menu code
    End IF

    Comments on this post

    • JimmyGosling agrees
    --

    ngibsonau

IMN logo majestic logo threadwatch logo seochat tools logo