Learn how to a build a cloud-first strategyRegister Now


Using ASp.Net inline function by Java Script (urgent)

Posted on 2005-04-27
Medium Priority
Last Modified: 2010-04-17
I want to use my asp.net function of inline code in java script function and expression.
I declarre vb programming code in inline of HTML Code i an aspx page.
How can i use a asp.net function in javascript or in HTML client and server control events.
<% @ Import Namespace=System.Data %>
<% @ Import Namespace=System.Data.Sqlclient %>

<Script Language="Vb" runat="Server">
Private Function xx(strName as string ) as Boolean
If strName="X" then
End Function


<script Language="Javascript">
function abc()
var ss;
var a;
a=xx(ss);      ''' display error to undefined  object or function.

a=</script><%=xx("asds") %> <scirpt Language="Javascript">  '''' Occur problem here also when i use this by type
<input type="text" name="a" onkeypress="xx('asa')">  '''' Display undefine function or objects

Plz Help me

Question by:cluster1
  • 2

Accepted Solution

doobdave earned 500 total points
ID: 13883844

I had a similar problem myself a while back,
but unfortunately I discovered that this is something that can't be done.

The vb code is compiled, and only HTML is sent to the client's browser (along with the javascript).

This means that the javascript code cannot 'see' the vb code, and therefore cannot call any functions defined by vb code.
LVL 13

Assisted Solution

softplus earned 500 total points
ID: 13884728
Correct, can't be done - without resorting to tricks:

What you can do however is have the Javascript call other asp-pages on your server with parameters, i.e. from page1.aspx, have the javascript redirect to "page2.aspx?item=newvalue" where newvalue is generated in the javascript (instead of redirecting you could also tell give the URL as the source of a picture, etc). This way you asp-script get's the feedback from your javascript. If you are passing things back and forth it will be a slow (and error prone) way, however...

This is done often with statistic-programs that want to know things from the client like browser type, display size, etc.

LVL 13

Expert Comment

ID: 14072956
Hi cluster, any luck so far or did we get it right :))?

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Simple Linear Regression

810 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