• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 515
  • Last Modified:

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

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
cluster1
Asked:
cluster1
  • 2
2 Solutions
 
doobdaveCommented:
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
 
softplusCommented:
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
 
softplusCommented:
Hi cluster, any luck so far or did we get it right :))?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now