[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

calling vb.net function inside the javascript tag in the code behind file

Posted on 2005-05-09
4
Medium Priority
?
860 Views
Last Modified: 2012-08-13
I have a textbox in which the user can scan the item no. All the items which are scanned/entered are being added in the grid below the text box.

I want that if the length of the item number is 7 ,page should be refreshed automatically and the item should be added in the grid.

txtItem.Attributes.Add("onKeyUp", "Javascript:if(document.forms[0].txtItem.value.length==7) { document.forms[0].txtSaleQty.focus();}")

the above code taked the focus to the txtSaleQty textbox when the length is 7. Is possible to do the following:

txtItem.Attributes.Add("onKeyUp", "Javascript:if(document.forms[0].txtItem.value.length==7) { CALL THE VB.NET FUNCTION BINDDATA}")

BINDDATA inserts the record in the database and refreshes the grid.

I tried adding the binddata in the TEXT CHANGED event of the txtItem textbox but the ENTER key has to be pressed to fire that event so that doesn't work for me.


Thanks.
0
Comment
Question by:wilkersons
  • 2
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
softplus earned 2000 total points
ID: 13963680
You need to set up a form for data entry, process the form on submit on the server side. You can't call a server-side function directly on the client side. Once you have the form, you can have it do " document.myform.submit(); " (assuming your form is named "myform") when you reach 7 characters.

e.g. (using your forms[0] to access the form)
txtItem.Attributes.Add("onKeyUp", "Javascript:if(document.forms[0].txtItem.value.length==7) { document.forms[0].submit();}")

Does that make sense? :)
0
 

Author Comment

by:wilkersons
ID: 13963775
Ok..somewhat!!

So adding  this
txtItem.Attributes.Add("onKeyUp", "Javascript:if(document.forms[0].txtItem.value.length==7) { document.forms[0].submit();}")

Should I add the BINDDATA procedure in the text changed event of the txtItem and set autopostback to true??
0
 
LVL 13

Expert Comment

by:softplus
ID: 13963807
Almost :) - Don't autopostback, you're submitting the form so there is no need for that. and yes, put your binddata procedure into the text changed event.
0
 

Author Comment

by:wilkersons
ID: 13968372
That works...thanks!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question