How to call javascript function from code behind

  • Thread starter Thread starter verci
  • Start date Start date
V

verci

Hi guys,
I'm running asp.net 2.0.

Does anyone know how to fire or call a javascript function from inside my
(VB.aspx) code without assigning it to a control attribute?

thank you
 
When you say "call javascript function" you mean actually executing it like
any normal .Net method from the server, but within the browser? *that*
cannot be done because there is no direct link between the client and the
server once the page has been handed to the browser.

If you mean something else, please fill me in becuase I'm confused.
 
OK, let me try to explain.

I've an external js file called functions.js, inside this file there's a
function jumpto() that takes a string parameter:
jumpto('MainPage/salaries.html')

which I call from my aspx page like this:

<a href="javascript:jumpto('MainPage/salaries.html')">Salary</a>

Now what I'm tryin to acheive is to passed the name of the html file via
querystring from page1 to page2.aspx like this:

Page1:

<a href="/comunidad/Articles.aspx?webPage=salaries">Totals</a>

Page 2:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

Dim mypage As String = ""

mypage = Request.QueryString("webPage") & ".html"

Page.ClientScript.RegisterStartupScript("script", "jumpto('MainPage/" +
mypage + "')", True)

End Sub



So far I'm stuck, any help would be very appreciated.

Best regards
 
I've just go it working!!! about five minutes ago

Thank you so much anyway for your help :)
 
Back
Top