473,721 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12824
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.val ue="ScanIsOk"

and server side

if request.form("h idField")="Scan IsOk" then....

ja**********@ep ower-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**********@ep ower-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**********@e power-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**********@e power-inc.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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
6905
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 end user, and yet still utilise some functions in the code-behind dll. Is this possible? (How?)
5
3540
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 and have another control with focus after the page loads from a different condition. A gets set in the code aspx.vb file and the script might look something like, <script language="javascript"> function DoHighlight(a) { if a = 1 {...
1
9746
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 function in code behind from onbeforeunload event call. but that is where I have a problem... please refer my code below
1
9885
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 <script> </script> area of the html source view of the corresponding aspx(asp.net)page. my requirement is how do i access the variable which i mentioned above in the c# code behind page?i need to use the variable in the javascript function. ...
3
15587
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) { this.AccountNumber.Text = AccountNumber; } I want to call this function from JavaScript (inside the window.onload function) from my MyPage.aspx page, something like below:
2
1877
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 matter what the value of b is. why is it so ?
1
1867
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 dtNewsList.Columns.Add("title") dtNewsList.Columns.Add("old") dtNewsList.Columns.Add("flaged")
1
3874
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
2828
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#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %> <%@ Import Namespace="System.IO" %> <HTML> <HEAD> <script type="text/javascript">
0
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.