473,378 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Call VB Code Behind Function from JavaScript???

I'm using JavaScript to capture a keypress in my web form. Right now
all it does is post an alert message box. Is there a way to have it
call a function in my VB code behind? All I really want to do is open
another web form when a certain key is pressed. I guess I'd also like
to be able to give focus to a specific textbox on the page when a key
is pressed.

In case you're wondering why... I am scanning in most of my values and
each barcode is prefixed according to the field it goes in, so when
"a123" is scanned, it will get put into a certain field no matter where
the cursor is on the page, and when "b123" is scanned, that will get
put into a certain field and so on.

Any suggestions would be appreciated. Thanks.

Jun 29 '06 #1
5 12809
U can use a work around with

document.forms(0).submit() in javascript

That will do a PostBack server-side

for branching, you can use a hidden

document.forms(0).hidField.value="ScanIsOk"

and server side

if request.form("hidField")="ScanIsOk" then....

ja**********@epower-inc.com wrote:
I'm using JavaScript to capture a keypress in my web form. Right now
all it does is post an alert message box. Is there a way to have it
call a function in my VB code behind? All I really want to do is open
another web form when a certain key is pressed. I guess I'd also like
to be able to give focus to a specific textbox on the page when a key
is pressed.

In case you're wondering why... I am scanning in most of my values and
each barcode is prefixed according to the field it goes in, so when
"a123" is scanned, it will get put into a certain field no matter where
the cursor is on the page, and when "b123" is scanned, that will get
put into a certain field and so on.

Any suggestions would be appreciated. Thanks.


Jun 29 '06 #2
The best approach is Ajax to access your codebehind in javascript:

See the atlas project page:

http://atlas.asp.net
ja**********@epower-inc.com wrote:
I'm using JavaScript to capture a keypress in my web form. Right now
all it does is post an alert message box. Is there a way to have it
call a function in my VB code behind? All I really want to do is open
another web form when a certain key is pressed. I guess I'd also like
to be able to give focus to a specific textbox on the page when a key
is pressed.

In case you're wondering why... I am scanning in most of my values and
each barcode is prefixed according to the field it goes in, so when
"a123" is scanned, it will get put into a certain field no matter where
the cursor is on the page, and when "b123" is scanned, that will get
put into a certain field and so on.

Any suggestions would be appreciated. Thanks.

Jun 29 '06 #3
If you want to actually make calls to Codebehind methods in your page via
client-side events, you need to either use Atlas (ASP.NET 2.0) or look into
Remote Scripting ("AJAX") libraries such as Anthem.NET, which is available on
sourceforge.net.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ja**********@epower-inc.com" wrote:
I'm using JavaScript to capture a keypress in my web form. Right now
all it does is post an alert message box. Is there a way to have it
call a function in my VB code behind? All I really want to do is open
another web form when a certain key is pressed. I guess I'd also like
to be able to give focus to a specific textbox on the page when a key
is pressed.

In case you're wondering why... I am scanning in most of my values and
each barcode is prefixed according to the field it goes in, so when
"a123" is scanned, it will get put into a certain field no matter where
the cursor is on the page, and when "b123" is scanned, that will get
put into a certain field and so on.

Any suggestions would be appreciated. Thanks.

Jun 29 '06 #4
this should all be easily done with client script, no need to bother the
server.

-- bruce (sqlwork.com)
<ja**********@epower-inc.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
I'm using JavaScript to capture a keypress in my web form. Right now
all it does is post an alert message box. Is there a way to have it
call a function in my VB code behind? All I really want to do is open
another web form when a certain key is pressed. I guess I'd also like
to be able to give focus to a specific textbox on the page when a key
is pressed.

In case you're wondering why... I am scanning in most of my values and
each barcode is prefixed according to the field it goes in, so when
"a123" is scanned, it will get put into a certain field no matter where
the cursor is on the page, and when "b123" is scanned, that will get
put into a certain field and so on.

Any suggestions would be appreciated. Thanks.

Jun 29 '06 #5
Got it. Thanks for the help!!

Jun 30 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fred Armitage | last post by:
I have a fairly complex application written using a vb code-behind dll. However, I'd like to write one particular aspx page utilising in-line code so that it can easily be modified as needed by the...
5
by: Paul | last post by:
Just wondering if someone could provide an example of passing a variable from the code behind to javascript in vb. I want to have one control have focus with the page loading with one condition...
1
by: lee_youjin | last post by:
I needed to defect when the user is clicking the IE X button ( top right). so I could execute the cleanup function. I was able to detect it using onbeforeunload event. Now I need to call the...
1
by: supin | last post by:
hi, i work in asp.net2.0/c#.not much expert in javascript.i have a variable declared in the c# code behind page.assume the variable contains some value. i have a javascript function in the...
3
by: akg | last post by:
Hi Gurus, I have a requirement like below. In my asp.net(C#) code behind file "MyPage.aspx.cs" file I have a function like below: void PopulateAccount(int AccountNumber) { ...
2
by: nams | last post by:
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...
1
by: vartana | last post by:
how can i call a none static function using javascript? javascript:GetData() Public Sub GetData() Dim objNL As New NLEngine Dim dtNewsList As New Data.DataTable ...
1
by: visweswaran2830 | last post by:
Hi, I have a function in aspx.vb (code behind fucntion). Now I want to call this function using javascript... How can I call?
0
by: raulbolanos | last post by:
I guys, I got 2 days trying to go thought this and I cannot figure out how to solve it, hope you can help me out here. I have a ASP Web Application, as simple as this; <%@ Page Language="C#"...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.