Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton, UK
    Posts
    282
    Thanks
    1
    Thanked 0 Times in 0 Posts

    running javascript from external js file

    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..

    Code:
    <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...
    Last edited by vinyl-junkie; 05-16-2007 at 05:05 AM. Reason: Added code tags
    <marquee>thanks</marquee>

  • #2
    New Coder
    Join Date
    Mar 2007
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you want to add an onclick attribute to a linkbutton, for example, you,d do like this:

    Code:
    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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •