Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2005-04-27
5
Medium Priority
?
508 Views
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.
Ex.
<% @ 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
   xx=True
Else
  xx=False
Endif
End Function

</script>

<script Language="Javascript">
function abc()
{
var ss;
var a;
ss="Naren";
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
}
<script>
<body>
<input type="text" name="a" onkeypress="xx('asa')">  '''' Display undefine function or objects



Plz Help me

0
Comment
Question by:cluster1
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
doobdave earned 500 total points
ID: 13883844
Cluster,

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.
0
 
LVL 13

Assisted Solution

by:softplus
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.

John
0
 
LVL 13

Expert Comment

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

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