Skip to content Skip to sidebar Skip to footer

How To Write Java Script In Vb.net Code?

Can anyone help me out as I need to write a Javascript in vb.net code? what i meant is i am new to vb.net coding, I have a dynamically created table from a web-service, and for tha

Solution 1:

you can not write javascript directly in vb.net code. However you can register and fire javascript from vb.net code.

Try this

Page.RegisterClientScriptBlock("key","<script>alert('Hello World');</script>");

Try this vb code block:

Dim strScript AsString = "<script>"
strScript += "alert('Hello, Pavan');"
strScript += "</script>"
Page.RegisterClientScriptBlock("strScript", strScript)

Solution 2:

You can not write javascript code in vb.net code. You can add/embed javascript code in vb.net code to execute on client. Usually you need to write javascript code in aspx page. You can use ScriptManager.RegisterClientScriptBlock to register the script from vb code.

Solution 3:

I can see that you're using

$('[id^=tname] th').live('click'...

From the jQuery docs however:

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live(). http://api.jquery.com/live/

In addition to that, TH is a really bad event target. As you'd need to click the TH, not the text within it. Otherwise your event won't trigger.

See the markup in here: http://jsfiddle.net/4eXkT/2/

That should work.

In reality, you don't need to embed any javascript into your vb.net code. Simply include a javascript file into your page and use the jQuery's .on() event handler. If you must manage the javascript from your web service, have another endpoint for returning the javascript to be used in accordance to your web service generated code.

If you MUST use any other version than the latest jQuery, please refer to the documentation provided above.

Post a Comment for "How To Write Java Script In Vb.net Code?"