...

View Full Version : running javascript from external js file



chris_angell
05-15-2007, 05:45 PM
Hi am trying to link to a JS file using ASP.NET 2.0 but i am having trouble ??? I have been trying different ways..


<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim scriptText As String
scriptText = "return confirm('Do you want to submit the page?')"
ClientScript.RegisterOnSubmitStatement(run(), "ConfirmSubmit", scriptText)

Dim myScript As String = "alert('hello');"
Page.ClientScript.RegisterStartupScript(run(), "myKey", myScript, True)
Page.ClientScript.RegisterClientScriptInclude(Me.GetType(), "LoginJS", "JScript.js")
End Sub
</script>

all i want to do is run a link from my aspx page that calls a functions from my javascript page onclick

on aspx onclick="run()"

talks to js page...

function run(){
alert("hello world")
}


any help will be good :)

cheers chris...

Krokador
05-16-2007, 07:20 PM
if you want to add an onclick attribute to a linkbutton, for example, you,d do like this:



lnkButton.Attributes.Add("onclick", "run();")


that's assuming you linked your js file to your page already. You can do this with most of the asp base controls.

os if you don't know how to actually link the file well... it,s the same as any html page. (<script src="script.js" language="javascript" ...></script>)

If thats not what youre searching for, maybe a bit more explanations would help me understand what you're trying to do?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum