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

Posted on 2005-04-27
Last Modified: 2010-04-17
I want to use my 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 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
    LVL 8

    Accepted Solution


    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

    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

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

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    INTRODUCTION We all know how to code. But at times you simply want to insert a common code block into your existing code and amend it as per your requirements. This tool not only saves you time but also saves you the pain of typing it all out aga…
    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now