Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Call VB Code Behind Function from JavaScript???

Reply
Thread Tools

Call VB Code Behind Function from JavaScript???

 
 
jason.gyetko@epower-inc.com
Guest
Posts: n/a
 
      06-29-2006
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.

 
Reply With Quote
 
 
 
 
DavidTurcotte
Guest
Posts: n/a
 
      06-29-2006
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....





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.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      06-29-2006
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




"" 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.
>
>

 
Reply With Quote
 
John Prado
Guest
Posts: n/a
 
      06-29-2006
The best approach is Ajax to access your codebehind in JavaScript:

See the atlas project page:

http://atlas.asp.net


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.
>

 
Reply With Quote
 
bruce barker \(sqlwork.com\)
Guest
Posts: n/a
 
      06-29-2006
this should all be easily done with client script, no need to bother the
server.

-- bruce (sqlwork.com)


<> wrote in message
news: 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.
>



 
Reply With Quote
 
jason.gyetko@epower-inc.com
Guest
Posts: n/a
 
      06-30-2006
Got it. Thanks for the help!!

 
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
Non-code behind to code behind John ASP .Net 2 02-19-2007 07:08 PM
Call a DLL LIB function in ASP.NET (Code Behind) or VB.NET (The same code is working fine in VB 6.0) Peri ASP .Net 2 07-20-2005 03:13 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Windows function call from aspx code behind? =?Utf-8?B?SGFydG11dCBTY2hyb3Ro?= ASP .Net 1 01-21-2004 07:51 PM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments