472,096 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

Calling Javascript Function from within VB Procedure?

Dear Group

I'm using VB to write an aspnet application. I would like to call a
javascript function from within a VB Sub or VB Function, is it possible? My
code is something like this:

VB Code:
Public Sub VBProcedure()
..
..
Run some VB Code...
..
..
Now call the javascript function

End Sub
------------------------------------------------------
javascript:
<HEAD>
<script language=javascript>
<!--
// MyFunction
function myfunction() {
window.open()
}
//-->
</script>
</HEAD>

I tried javascript: myfunction() within the VB procedure. Well, it was just
a blind guess since the 'javascript:' syntax did not produce any errors.
What is 'javascript:' all about? I can't find it documented.

Thanks for your help & efforts!

Martin

Nov 20 '05 #1
4 6109
Cor
Hi Martin,

The most simple sample.

\\\
Dim str As String
str = "<script language=javascript> {window.open('http://www.google.com');}
</script>"
RegisterStartupScript("Startup", str)
///

I hope this helps a little bit?

Cor
Dear Group

I'm using VB to write an aspnet application. I would like to call a
javascript function from within a VB Sub or VB Function, is it possible? My code is something like this:

VB Code:
Public Sub VBProcedure()
.
.
Run some VB Code...
.
.
Now call the javascript function

End Sub
------------------------------------------------------
javascript:
<HEAD>
<script language=javascript>
<!--
// MyFunction
function myfunction() {
window.open()
}
//-->
</script>
</HEAD>

I tried javascript: myfunction() within the VB procedure. Well, it was just a blind guess since the 'javascript:' syntax did not produce any errors.
What is 'javascript:' all about? I can't find it documented.

Thanks for your help & efforts!

Martin

Nov 20 '05 #2

Hi Cor

Thanks for your message.
Well, I'm not exactly sure whether that's the answer to my problem. After
having had a look at the RegisterScript Methods, it seems to me that it is
just a convenient way to inject the Javascript into the page. I can do this
by writing it directly in the HTML view in VS. Or is there a difference.
Once having the Javsscript registered, I still need a HTML button on my page
whick calls the Javascript in the OnClick Event.

However in my case, I'm calling a VB Sub with the OnItemCommand Event of the
Datagrid to look up some data depending on the value choosen nin the
datagrid. So the OnItemCommand for the datagrid is already taken. At the
same time when the OnItemCommand Event fires I also would like to execute a
client-side Javascript function after the data has been looked up.
So I thought I'm calling the Javascript from within the VB Sub in which I
look up the data after completion of look-up.

Any possible way to achive this?

Thanks for your help & efforts!

Kind Regards,

Martin

"Cor" <no*@non.com> wrote in message
news:#M**************@tk2msftngp13.phx.gbl...
Hi Martin,

The most simple sample.

\\\
Dim str As String
str = "<script language=javascript> {window.open('http://www.google.com');} </script>"
RegisterStartupScript("Startup", str)
///

I hope this helps a little bit?

Cor
Dear Group

I'm using VB to write an aspnet application. I would like to call a
javascript function from within a VB Sub or VB Function, is it possible?

My
code is something like this:

VB Code:
Public Sub VBProcedure()
.
.
Run some VB Code...
.
.
Now call the javascript function

End Sub
------------------------------------------------------
javascript:
<HEAD>
<script language=javascript>
<!--
// MyFunction
function myfunction() {
window.open()
}
//-->
</script>
</HEAD>

I tried javascript: myfunction() within the VB procedure. Well, it was

just
a blind guess since the 'javascript:' syntax did not produce any errors.
What is 'javascript:' all about? I can't find it documented.

Thanks for your help & efforts!

Martin


Nov 20 '05 #3
Hi Cor

Thanks for your message.
Well, I'm not exactly sure whether that's the answer to my problem. After
having had a look at the RegisterScript Methods, it seems to me that it is
just a convenient way to inject the Javascript into the page. I can do this
by writing it directly in the HTML view in VS. Or is there a difference.
Once having the Javsscript registered, I still need a HTML button on my page
whick calls the Javascript in the OnClick Event.

However in my case, I'm calling a VB Sub with the OnItemCommand Event of the
Datagrid to look up some data depending on the value choosen nin the
datagrid. So the OnItemCommand for the datagrid is already taken. At the
same time when the OnItemCommand Event fires I also would like to execute a
client-side Javascript function after the data has been looked up.
So I thought I'm calling the Javascript from within the VB Sub in which I
look up the data after completion of look-up.

Any possible way to achive this?

Thanks for your help & efforts!

Kind Regards,

Martin

"Martin Feuersteiner" <th************@hotmail.com> wrote in message
news:c1**********@sparta.btinternet.com...
Dear Group

I'm using VB to write an aspnet application. I would like to call a
javascript function from within a VB Sub or VB Function, is it possible? My code is something like this:

VB Code:
Public Sub VBProcedure()
.
.
Run some VB Code...
.
.
Now call the javascript function

End Sub
------------------------------------------------------
javascript:
<HEAD>
<script language=javascript>
<!--
// MyFunction
function myfunction() {
window.open()
}
//-->
</script>
</HEAD>

I tried javascript: myfunction() within the VB procedure. Well, it was just a blind guess since the 'javascript:' syntax did not produce any errors.
What is 'javascript:' all about? I can't find it documented.

Thanks for your help & efforts!

Martin

Nov 20 '05 #4
Cor
Hi Martin,

I said that was the simplest one. And I have not direct the answer to your
datagrid, but look also look at this sample (you have to find the postback
event from the datagrid, than I think this will work than also).

\\\A webform with an imagebutton and two bitmaps in the solution map
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.ImageButton1.ImageUrl = "bitmap2.bmp"
Me.ImageButton1.Attributes("onmouseover") = "this.src='bitmap1.bmp';"
Me.ImageButton1.Attributes("onmouseout") = "this.src='bitmap2.bmp';"
Me.ImageButton1.Attributes("onClick") = _
"window.location='mailto:no*@non.com?subject=C or demo&body=I hope this
helps?';"
End Sub
///

I hope this helps a little bit?

Cor
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

30 posts views Thread by Tim Marshall | last post: by
4 posts views Thread by Zeebra3 | last post: by
3 posts views Thread by Shiraz | last post: by
5 posts views Thread by Stephen Plotnick | last post: by
4 posts views Thread by raghuvendra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.