Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004
    Location
    USA
    Posts
    54

    Unanswered: Using onClick in <A Href="abc.asp"> - ASP & VBScript

    I am trying to use onClick event inside the

    <A Href="abc.asp" onclick= "call a Sub or Function">Click here</A>,

    so that when user clicks the 'Click Here' link, instead of going directly to the specified link, I will call the Subroutine (or Function) to check his security level to decide if he can go on to the link, or be rejected (i.e. not respond to his click except just displaying a message to let him know).

    Can anyone help me with this? Thanks.

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    You're trying to cross Server-Side and Client-Side programming. The best way you're going to accomplish this would be to use some JavaScript to submit the login info to a hidden IFrame which would validate the credentials, and either display an error, or set a cookie/session and redirect the user to the secured page.

    Personally, I don't use IFrames for this purpose. I simply submit the credentials on the same page and attempt to authenticate. If it fails, I redirect them back to the original login form with an error message, otherwise I redirect them to the secured page.

    What is the business need, or is strictly aesthetic?
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    Aug 2004
    Location
    USA
    Posts
    54
    Thanks for the direction.

    Now, I have another related question, and here's my codes:

    <A href="<%=some file%>" target="_blank"
    onClick="window.open ('<%=some file%>','','width=950,height=600,scrollbars=yes,me nubar=yes');return false;">
    Click Here</A>


    Here, when users click the link, it will open a new window (with the pre-determined features and sizes, etc.).

    But now, I need to use an ASP IF statement to check some condition so that if the condition is FALSE, I will still show the words "Click Here" without the underline and also ignoring the onClick event. How do I insert this IF statement in this <A></A> tag?

    Basically, I am trying to wrap an ASP <%IF...Then %> statement around this following line:

    onclick="open('<%=some file%>','','');return false;

    But I have <% %> already inside this onClick event?!
    Last edited by rweide; 09-10-04 at 15:35.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •