Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Passing VB to javascript

Reply
Thread Tools

Passing VB to javascript

 
 
Ruskin
Guest
Posts: n/a
 
      04-02-2004
I have seen a couple of web sites that detail how to do this, but seem to be
overlooking the obvious.... I have the following code and have tried
variations to get it working;


<!--#INCLUDE FILE="CommonFunctions.inc"-->
<%
'following is vb script....
if not MyFunction(check_field) then 'This function is in the
include
DisplayError("this failed")
else
ContinueProcess 'This sub routine is
in the include
end if

sub DisplayError(iErr)
%>
<SCRIPT language="javascript">
alert( <%= iErr %>);
history.go(-1);
</SCRIPT>
<%
end sub

%>

I want to pass different messages to the displayerror function, but just
can't seem to make it work... Any ideas?


 
Reply With Quote
 
 
 
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      04-02-2004
You're going to have to think about it slightly differently. The main
reason is you think all of this script interacts, when in fact, first the
ASP runs, then the client-side script runs. Let's look at it this way:

<%
sub showError(iErr)
response.write "<script>" & vbCrLf & _
"alert('" & replace(iErr,"'","\'") & "');" & _
"history.go(-1);" & vbCrLf & _
"</script>"
response.end
end sub

' play with making something true
' and somethingElse true

something = false
somethingElse = false

if something then
showError "this failed"
end if

if somethingElse then
showError "that failed"
end if
%>

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Ruskin" <> wrote in message
news:TC4bc.2418$d%...
>I have seen a couple of web sites that detail how to do this, but seem to
>be
> overlooking the obvious.... I have the following code and have tried
> variations to get it working;
>
>
> <!--#INCLUDE FILE="CommonFunctions.inc"-->
> <%
> 'following is vb script....
> if not MyFunction(check_field) then 'This function is in the
> include
> DisplayError("this failed")
> else
> ContinueProcess 'This sub routine is
> in the include
> end if
>
> sub DisplayError(iErr)
> %>
> <SCRIPT language="javascript">
> alert( <%= iErr %>);
> history.go(-1);
> </SCRIPT>
> <%
> end sub
>
> %>
>
> I want to pass different messages to the displayerror function, but just
> can't seem to make it work... Any ideas?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing an array from FORTRAN to C then passing it within C andReturning it to FORTRAN deadpickle C Programming 1 11-07-2010 02:38 PM
Passing parameters to an executable vs. passing them to a server Ramon F Herrera C++ 8 09-13-2009 02:48 AM
passing copy of a pointer to a variable vs passing the copy pereges C Programming 7 06-01-2008 02:36 PM
Passing by const & and returning a temp vs passing by value and returningit Victor Bazarov C++ 25 03-23-2005 04:24 PM
Passing data to use with client javascript Alfredo Magallón Arbizu ASP .Net 1 11-20-2003 02:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57