client side asp within server side asp

Discussion in 'ASP General' started by JT, Sep 9, 2004.

  1. JT

    JT Guest

    im trying to use the following code to log whenever a user clicks through
    this particlular message box - however, this currently logs regardless of
    whether or not the message box was clicked - im assuming this is because the
    server-side code can't see the client side if condition. but how can i set
    the varMsgBox variable as a server-side variable?

    <!--switch to client-side VBScript to use the MsgBox-->
    <script language="VBSCRIPT">
    dim varMsgBox
    varMsgBox = "0"
    varMsgBox = MsgBox ("<%=pop_up_text%>", 16, "Urgent Message")
    'log that user clicked through the pop-up message - switch back to
    server-side to call function to insert log message into the db
    if varMsgBox = "1" then
    <% Call dumplogfile("User clicked through the pop-up message: " &
    pop_up_text)%>
    end if
    </script>
     
    JT, Sep 9, 2004
    #1
    1. Advertising

  2. JT wrote:
    > im trying to use the following code to log whenever a user clicks
    > through this particlular message box - however, this currently logs
    > regardless of whether or not the message box was clicked - im
    > assuming this is because the server-side code can't see the client
    > side if condition. but how can i set the varMsgBox variable as a
    > server-side variable?
    >

    You can't. All server-side code runs before client-side code is processed.


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Sep 9, 2004
    #2
    1. Advertising

  3. JT

    JT Guest

    but isn't there a way to somehow do it along the lines of what is discussed
    in this article?

    http://www.aspfaq.com/show.asp?id=2198


    "Bob Barrows [MVP]" <> wrote in message
    news:...
    > JT wrote:
    > > im trying to use the following code to log whenever a user clicks
    > > through this particlular message box - however, this currently logs
    > > regardless of whether or not the message box was clicked - im
    > > assuming this is because the server-side code can't see the client
    > > side if condition. but how can i set the varMsgBox variable as a
    > > server-side variable?
    > >

    > You can't. All server-side code runs before client-side code is processed.
    >
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
     
    JT, Sep 9, 2004
    #3
  4. JT

    Bob Lehmann Guest

    No, because by the time the message box comes up, control has switched to
    the client.

    Bob Lehmann

    "JT" <> wrote in message
    news:...
    > but isn't there a way to somehow do it along the lines of what is

    discussed
    > in this article?
    >
    > http://www.aspfaq.com/show.asp?id=2198
    >
    >
    > "Bob Barrows [MVP]" <> wrote in message
    > news:...
    > > JT wrote:
    > > > im trying to use the following code to log whenever a user clicks
    > > > through this particlular message box - however, this currently logs
    > > > regardless of whether or not the message box was clicked - im
    > > > assuming this is because the server-side code can't see the client
    > > > side if condition. but how can i set the varMsgBox variable as a
    > > > server-side variable?
    > > >

    > > You can't. All server-side code runs before client-side code is

    processed.
    > >
    > >
    > > --
    > > Microsoft MVP -- ASP/ASP.NET
    > > Please reply to the newsgroup. The email account listed in my From
    > > header is my spam trap, so I don't check it very often. You will get a
    > > quicker response by posting to the newsgroup.
    > >
    > >

    >
    >
     
    Bob Lehmann, Sep 9, 2004
    #4
  5. No, that article talks about what you've successfully done: cause a
    client-side action from from server-side code. It's a one-way street. Data
    can only be passed to server-side code via the Request object, which only
    exists when the page is initially called.

    To do what you want will involve another page.

    Bob Barrows

    JT wrote:
    > but isn't there a way to somehow do it along the lines of what is
    > discussed in this article?
    >
    > http://www.aspfaq.com/show.asp?id=2198
    >
    >
    > "Bob Barrows [MVP]" <> wrote in message
    > news:...
    >> JT wrote:
    >>> im trying to use the following code to log whenever a user clicks
    >>> through this particlular message box - however, this currently logs
    >>> regardless of whether or not the message box was clicked - im
    >>> assuming this is because the server-side code can't see the client
    >>> side if condition. but how can i set the varMsgBox variable as a
    >>> server-side variable?
    >>>

    >> You can't. All server-side code runs before client-side code is
    >> processed.
    >>
    >>
    >> --
    >> Microsoft MVP -- ASP/ASP.NET
    >> Please reply to the newsgroup. The email account listed in my From
    >> header is my spam trap, so I don't check it very often. You will get
    >> a quicker response by posting to the newsgroup.


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Sep 9, 2004
    #5
  6. 1. With your particular example, will the response from your msgbox ever be
    anything but 1? You don't leave the user many options when you have only
    "vbOK"

    2. Since your usage of VBScript in the browser already indicates you are
    into doing things in an unorthodox way (said with a "<g>" of course!), you
    could do something like so:

    yourpage.asp:

    <%
    Dim pop_up_text
    pop_up_text = "All your base are belong to us"
    %>
    <img id="x" style="display:none;" />

    <script type="text/javascript">
    //sorry, I cannot bring myself to use vbscript,

    if(confirm('<%=pop_up_text%>')) {
    var o = document.getElementById('x');
    x.src =
    './process.asp?user=IdentifiedSomehow&m=<%=Server.URLEncode(pop_up_text)%>';
    }
    </script>



    process.asp:

    <%
    Dim sUser, sMessage, oCDO
    sUser = Request.Querystring("user")
    sMessage = Request.Querystring("m")
    Set oCDO = CreateObject("CDO.Message")
    oCDO.From = ""
    oCDO.To = ""
    oCDO.Subject = "User clicked OK"
    oCDO.TextBody = sUser & " clicked OK to a prompt of " & sMessage
    oCDO.Send
    Set oCDO = Nothing
    %>




    Ray at work





    "JT" <> wrote in message
    news:...
    > but isn't there a way to somehow do it along the lines of what is
    > discussed
    > in this article?
    >
    > http://www.aspfaq.com/show.asp?id=2198
    >
    >
    > "Bob Barrows [MVP]" <> wrote in message
    > news:...
    >> JT wrote:
    >> > im trying to use the following code to log whenever a user clicks
    >> > through this particlular message box - however, this currently logs
    >> > regardless of whether or not the message box was clicked - im
    >> > assuming this is because the server-side code can't see the client
    >> > side if condition. but how can i set the varMsgBox variable as a
    >> > server-side variable?
    >> >

    >> You can't. All server-side code runs before client-side code is
    >> processed.
    >>
    >>
    >> --
    >> Microsoft MVP -- ASP/ASP.NET
    >> Please reply to the newsgroup. The email account listed in my From
    >> header is my spam trap, so I don't check it very often. You will get a
    >> quicker response by posting to the newsgroup.
    >>
    >>

    >
    >
     
    Ray Costanzo [MVP], Sep 10, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page