Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Javascript in VB class

Reply
Thread Tools

Javascript in VB class

 
 
Brian Henry
Guest
Posts: n/a
 
      06-11-2004
Is there a way to launch a javascript command from within VB code? For
instance, to issue a window.open(some url) if a certain condition is met. I
know you can add the javacript to a control event at runtime, but i need to
just launch it, not wait for the user to click something.

Thanks


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      06-11-2004
No. "VB Code" is server-side. JavaScript is client-side. And never the twain
shall meet.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Brian Henry" <> wrote in message
news:#W#...
> Is there a way to launch a javascript command from within VB code? For
> instance, to issue a window.open(some url) if a certain condition is met.

I
> know you can add the javacript to a control event at runtime, but i need

to
> just launch it, not wait for the user to click something.
>
> Thanks
>
>



 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      06-11-2004
Just bind your javascript to the appropriate client side event (such as the
the onload attribute of the body tag). It will be always performed client
side anyway.

Patrice

--

"Brian Henry" <> a écrit dans le message de
news:%23W%...
> Is there a way to launch a javascript command from within VB code? For
> instance, to issue a window.open(some url) if a certain condition is met.

I
> know you can add the javacript to a control event at runtime, but i need

to
> just launch it, not wait for the user to click something.
>
> Thanks
>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      06-11-2004
"Brian Henry" <> wrote in message
news:%23W%...
> Is there a way to launch a javascript command from within VB code? For
> instance, to issue a window.open(some url) if a certain condition is met.

I
> know you can add the javacript to a control event at runtime, but i need

to
> just launch it, not wait for the user to click something.


JavaScript is just text in a response the server sends to the client. Unless
you are sending text to the client, there will be no JavaScript. The only
time you can send text to the client is at the end of the request.

Also, you seem to have some code, and you want that code to launch some
JavaScript. But how did that code get called if the user didn't click
anything?
--
John Saunders
johnwsaundersiii at hotmail


 
Reply With Quote
 
Brian Henry
Guest
Posts: n/a
 
      06-11-2004
It's kind of like a validation function, kind of hard to explain.
Basically, when the user clicks a button, i want to run a small function,
and then if and only if a certain condition fails do i run the javascript.

"John Saunders" <> wrote in message
news:...
> "Brian Henry" <> wrote in message
> news:%23W%...
> > Is there a way to launch a javascript command from within VB code? For
> > instance, to issue a window.open(some url) if a certain condition is

met.
> I
> > know you can add the javacript to a control event at runtime, but i need

> to
> > just launch it, not wait for the user to click something.

>
> JavaScript is just text in a response the server sends to the client.

Unless
> you are sending text to the client, there will be no JavaScript. The only
> time you can send text to the client is at the end of the request.
>
> Also, you seem to have some code, and you want that code to launch some
> JavaScript. But how did that code get called if the user didn't click
> anything?
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      06-11-2004
"Brian Henry" <> wrote in message
news:...
> It's kind of like a validation function, kind of hard to explain.
> Basically, when the user clicks a button, i want to run a small function,
> and then if and only if a certain condition fails do i run the javascript.


I'm sorry, but I'm afraid you're should learn a bit more about the execution
model of ASP.NET before tackling this task. Perhaps this will help: The
ASP.NET Page Object Model
(http://msdn.microsoft.com/library/de...-us/dnaspp/htm
l/aspnet-pageobjectmodel.asp?frame=true). Realize that this happens on the
initial request, and on _every_ postback.
--
John Saunders
johnwsaundersiii at hotmail


> "John Saunders" <> wrote in message
> news:...
> > "Brian Henry" <> wrote in message
> > news:%23W%...
> > > Is there a way to launch a javascript command from within VB code?

For
> > > instance, to issue a window.open(some url) if a certain condition is

> met.
> > I
> > > know you can add the javacript to a control event at runtime, but i

need
> > to
> > > just launch it, not wait for the user to click something.

> >
> > JavaScript is just text in a response the server sends to the client.

> Unless
> > you are sending text to the client, there will be no JavaScript. The

only
> > time you can send text to the client is at the end of the request.
> >
> > Also, you seem to have some code, and you want that code to launch some
> > JavaScript. But how did that code get called if the user didn't click
> > anything?
> > --
> > John Saunders
> > johnwsaundersiii at hotmail
> >
> >

>
>



 
Reply With Quote
 
Justin Beckwith
Guest
Posts: n/a
 
      06-12-2004
If you want to validate something in client side code before you
submit, bind a client side event to your submit button.


**** server code ****
myBtn.Attributes.Add("OnClick","return Validate();");


**** client code ****
function Validate() {
// do some logic
return true or false;
}

when the use clicks the button, the client side validation method is
called, and if you return true, the form will post.
 
Reply With Quote
 
Anand Sagar
Guest
Posts: n/a
 
      06-16-2004
Eg. VB.Net code:

If flag = true the
response.write("<script language = 'javascript'>alert('the flag was
succesful');</script>")
else
response.write("<script language = 'javascript'>alert('the flag was
Unsuccesful');</script>")
end if


Sagar.

"Brian Henry" <> wrote in message
news:%23W%...
> Is there a way to launch a javascript command from within VB code? For
> instance, to issue a window.open(some url) if a certain condition is met.

I
> know you can add the javacript to a control event at runtime, but i need

to
> just launch it, not wait for the user to click something.
>
> Thanks
>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      06-16-2004
"Anand Sagar" <> wrote in message
news:...
> Eg. VB.Net code:
>
> If flag = true the
> response.write("<script language = 'javascript'>alert('the flag was
> succesful');</script>")
> else
> response.write("<script language = 'javascript'>alert('the flag was
> Unsuccesful');</script>")
> end if


This VB.NET code will have been executed in response to a user action, e.g.
a click.
--
John Saunders
johnwsaundersiii at hotmail


> "Brian Henry" <> wrote in message
> news:%23W%...
> > Is there a way to launch a javascript command from within VB code? For
> > instance, to issue a window.open(some url) if a certain condition is

met.
> I
> > know you can add the javacript to a control event at runtime, but i need

> to
> > just launch it, not wait for the user to click something.
> >
> > Thanks
> >
> >

>
>



 
Reply With Quote
 
Alexander Kaplunov
Guest
Posts: n/a
 
      06-16-2004
What if I wanted to call my of function test() ? How would I do that?

Response.Write("<script language = 'javascript'>test();</script>");

....dows not work



"Anand Sagar" <> wrote in message
news:...
> Eg. VB.Net code:
>
> If flag = true the
> response.write("<script language = 'javascript'>alert('the flag was
> succesful');</script>")
> else
> response.write("<script language = 'javascript'>alert('the flag was
> Unsuccesful');</script>")
> end if
>
>
> Sagar.
>
> "Brian Henry" <> wrote in message
> news:%23W%...
> > Is there a way to launch a javascript command from within VB code? For
> > instance, to issue a window.open(some url) if a certain condition is

met.
> I
> > know you can add the javacript to a control event at runtime, but i need

> to
> > just launch it, not wait for the user to click something.
> >
> > Thanks
> >
> >

>
>



 
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
Class A contains class B, class B points to class A Joseph Turian C++ 5 12-30-2005 03:24 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM
Generic class literals - e.g,, Class<Map<String, Integer>>.class Purush Java 4 04-13-2005 08:40 PM
instanciate a class in a jar file with class.forname, while my main class is in another jar cyril Java 2 08-25-2004 06:55 AM



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