469,323 Members | 1,493 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Calling code-behind from javascript

Hi Frnds,

Say I have vb code like this:

Public Sub ll()
MsgBox("heLOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", MsgBoxStyle.OkOnly)
End Sub

The following script runs as soon as the page loads, no matter what
the value of b is. why is it so ?

<script type="text/javascript" language="javascript">
function ss()
{
var b = 1;
if(b==2)
{
<% ll() %>;
}
}
</script>

I want the code to get executed only if the if-condition is true and
also only when i call the script - i mean not as soon as the page
loads. Please help me.

Thanks,
Nams here
Feb 26 '08 #1
2 1630
On Feb 26, 4:57*am, nams <namsSof...@gmail.comwrote:
Hi Frnds,

Say I have vb code like this:

*Public Sub ll()
* * * * MsgBox("heLOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", MsgBoxStyle.OkOnly)
* * End Sub
This is not a VB.NET group. But as I am somewhat familiar with .NET,
I can tell you that you are very confused (not an uncommon state
among .NET developers.)

Try searching for a VB.NET group.

[snip]
Feb 26 '08 #2
nams wrote on 26 feb 2008 in comp.lang.javascript:
Hi Frnds,

Say I have vb code like this:

Public Sub ll()
MsgBox("heLOOOOOOOOOOOOOOOOOOOOOOOOOOOOO", MsgBoxStyle.OkOnly)
End Sub

The following script runs as soon as the page loads, no matter what
the value of b is. why is it so ?
VB does not run on a server, nor on a browser,
vb is a compiling language.

VBscript can run on a server under ASP,
or on an IE browser on the client.

You seam to mean this to be serverside vbs code, as you show the <% %>
below.

Calling MsgBox() on a server in ASP-vbs is futile, as many servers do not
evn have a screen, and ASP has no rights displaying on the server, and if
you have 20 or 1000 concurrent users, whose MsgBox would it be that
should be displayed on the server's possibly absent dislay?

<script type="text/javascript" language="javascript">
language="javascript" can be left out.
function ss()
{
var b = 1;
if(b==2)
{
<% ll() %>;
When the clientside code is executed on the browser, the server is
already finished with it.

Only any resulting text stream is inserted for the browser to be executed
ON THE CLIENT. Your serverside sub does NOT produce any clientside code.
}
}
</script>

I want the code to get executed only if the if-condition is true and
The if condition in your code above is never true.
also only when i call the script - i mean not as soon as the page
loads. Please help me.
You can call a NEW serverside page from the client/browser by using the
Ajax technique, but even then displaying a MsgBox on the server display
seems not usefull and is impossible.
Thanks,
Nams here
Please rethink the difference between serverside script execution and
clientside script execution.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 26 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Muthu | last post: by
7 posts views Thread by Klaus Friese | last post: by
1 post views Thread by Jesse McGrew | last post: by
5 posts views Thread by Nick Flandry | last post: by
3 posts views Thread by Mike | last post: by
2 posts views Thread by Geler | last post: by
16 posts views Thread by teju | last post: by
7 posts views Thread by =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.