Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Javascript in VB class

 
 
John Saunders
Guest
Posts: n/a
 
      06-17-2004
"Alexander Kaplunov" <(E-Mail Removed)> wrote in message
news:OzZURz$(E-Mail Removed)...
> 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


Could you please provide some detail? Exactly how does it "not work"?

And did you define a function called "test"?
--
John Saunders
johnwsaundersiii at hotmail


> "Anand Sagar" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:%23W%(E-Mail Removed)...
> > > 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-17-2004
Yes I do have test function defined.

When I execute the code I get error on the page "Error: Object expected"

I can execute alert(), window.open(), etc. functions but not functions that
I define.

Thanks for your help.
Alex.

"John Saunders" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> "Alexander Kaplunov" <(E-Mail Removed)> wrote in message
> news:OzZURz$(E-Mail Removed)...
> > 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

>
> Could you please provide some detail? Exactly how does it "not work"?
>
> And did you define a function called "test"?
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>
> > "Anand Sagar" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote in message
> > > news:%23W%(E-Mail Removed)...
> > > > 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-17-2004
"Alexander Kaplunov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes I do have test function defined.
>
> When I execute the code I get error on the page "Error: Object expected"
>
> I can execute alert(), window.open(), etc. functions but not functions

that
> I define.


Can you create a reproducer and show us the code?
--
John Saunders
johnwsaundersiii at hotmail

> "John Saunders" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > "Alexander Kaplunov" <(E-Mail Removed)> wrote in message
> > news:OzZURz$(E-Mail Removed)...
> > > 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

> >
> > Could you please provide some detail? Exactly how does it "not work"?
> >
> > And did you define a function called "test"?
> > --
> > John Saunders
> > johnwsaundersiii at hotmail
> >
> >
> > > "Anand Sagar" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > 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" <(E-Mail Removed)> wrote in message
> > > > news:%23W%(E-Mail Removed)...
> > > > > 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-17-2004
Sure. Here is it:

Client code:

function test()
{
alert("Got test!");
}

Code-behind (server)
public void Button2_Click(object sender, System.EventArgs e)
{

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

}



Thanks, Alex.

"John Saunders" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> "Alexander Kaplunov" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Yes I do have test function defined.
> >
> > When I execute the code I get error on the page "Error: Object expected"
> >
> > I can execute alert(), window.open(), etc. functions but not functions

> that
> > I define.

>
> Can you create a reproducer and show us the code?
> --
> John Saunders
> johnwsaundersiii at hotmail
>
> > "John Saunders" <(E-Mail Removed)> wrote in message
> > news:#(E-Mail Removed)...
> > > "Alexander Kaplunov" <(E-Mail Removed)> wrote in message
> > > news:OzZURz$(E-Mail Removed)...
> > > > 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
> > >
> > > Could you please provide some detail? Exactly how does it "not work"?
> > >
> > > And did you define a function called "test"?
> > > --
> > > John Saunders
> > > johnwsaundersiii at hotmail
> > >
> > >
> > > > "Anand Sagar" <(E-Mail Removed)> wrote in message
> > > > news:(E-Mail Removed)...
> > > > > 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" <(E-Mail Removed)> wrote in message
> > > > > news:%23W%(E-Mail Removed)...
> > > > > > 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
 
Anand Sagar
Guest
Posts: n/a
 
      06-17-2004
You cannot call a explicitly written at design time js function from a
Response.Write call. You have to write the complete text of the function at
run-time

Here is a VB.Net code for it.

Dim JString as String

jString = "function Test(){"
jString += "alert('this is a line inside the finction');"
jString += "}"

Response.Write("<script language = 'javascript'>" + jString + "</script>")


"Alexander Kaplunov" <(E-Mail Removed)> wrote in message
news:OzZURz$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:%23W%(E-Mail Removed)...
> > > 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-17-2004
This code does not cause an error but it does not call the Test() function
either. Basically, nothing happens.

Alex.

"Anand Sagar" <(E-Mail Removed)> wrote in message
news:uZNlA#(E-Mail Removed)...
> You cannot call a explicitly written at design time js function from a
> Response.Write call. You have to write the complete text of the function

at
> run-time
>
> Here is a VB.Net code for it.
>
> Dim JString as String
>
> jString = "function Test(){"
> jString += "alert('this is a line inside the finction');"
> jString += "}"
>
> Response.Write("<script language = 'javascript'>" + jString +

"</script>")
>
>
> "Alexander Kaplunov" <(E-Mail Removed)> wrote in message
> news:OzZURz$(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote in message
> > > news:%23W%(E-Mail Removed)...
> > > > 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
 
marcelito69 marcelito69 is offline
Junior Member
Join Date: Oct 2009
Posts: 1
 
      10-27-2009
this is very easy...start with this....write an html page including your javascript...embedd an IE control in your vb form...call the navigate method with your html file as url address....that's it folks!






Quote:
Originally Posted by Brian Henry
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