Including Java Scripts in Server controls

Discussion in 'ASP .Net Building Controls' started by Sundararajan, Apr 12, 2005.

  1. Sundararajan

    Sundararajan Guest

    Dear Folks,

    I am developing a server control as a composite control. I need to
    associate some javascripts with the individual controls of the composite
    control.
    I have the javascrips in a separate .js file. how can i associate the
    functions in .js file with the server controls.

    Thanx in advance

    Regards,
    --
    S.Sundararajan
    Sundararajan, Apr 12, 2005
    #1
    1. Advertising

  2. hi,

    Add an include line to link the js file to your page,
    This can be done using Page.Registerstartupscript("Key","Script")
    Once the js file is linked with ur page, you can assign the methods in the
    js file to the control events.
    Ex: btnButton.Attributes.Add("OnClick", "YourJSfunction");

    play around with this and you'll get to know a lot more...

    Regds
    Kannan.V

    "Sundararajan" wrote:

    > Dear Folks,
    >
    > I am developing a server control as a composite control. I need to
    > associate some javascripts with the individual controls of the composite
    > control.
    > I have the javascrips in a separate .js file. how can i associate the
    > functions in .js file with the server controls.
    >
    > Thanx in advance
    >
    > Regards,
    > --
    > S.Sundararajan
    Kannan.V [MCSD.net], Apr 12, 2005
    #2
    1. Advertising

  3. hi,

    Add an include line to link the js file to your page,
    This can be done using Page.Registerstartupscript("Key","Script")
    Once the js file is linked with ur page, you can assign the methods in the
    js file to the control events.
    Ex: btnButton.Attributes.Add("OnClick", "YourJSfunction");

    play around with this and you'll get to know a lot more...

    Regds
    Kannan.V

    "Sundararajan" wrote:

    > Dear Folks,
    >
    > I am developing a server control as a composite control. I need to
    > associate some javascripts with the individual controls of the composite
    > control.
    > I have the javascrips in a separate .js file. how can i associate the
    > functions in .js file with the server controls.
    >
    > Thanx in advance
    >
    > Regards,
    > --
    > S.Sundararajan
    Kannan.V [MCSD.net], Apr 12, 2005
    #3
  4. Sundararajan

    Brock Allen Guest

    You want Page.RegisterClientScriptBlock to register a block of functions.
    You'll need to add your own <script language=...> in your script (the 2nd
    param to the method).

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Dear Folks,
    >
    > I am developing a server control as a composite control. I need to
    > associate some javascripts with the individual controls of the
    > composite control. I have the javascrips in a separate .js file. how
    > can i associate the functions in .js file with the server controls.
    >
    > Thanx in advance
    >
    > Regards,
    >
    Brock Allen, Apr 12, 2005
    #4
  5. Sundararajan

    Dale Preston Guest

    In your server control, do something like:

    Response.Write("<script src='" + myScriptFileUrl + "'></script>");

    That will cause the browser to load the javascript file.

    HTH

    Dale Preston
    MCAD, MCDBA, MCSE


    "Sundararajan" <> wrote in message
    news:...
    > Dear Folks,
    >
    > I am developing a server control as a composite control. I need to
    > associate some javascripts with the individual controls of the composite
    > control.
    > I have the javascrips in a separate .js file. how can i associate the
    > functions in .js file with the server controls.
    >
    > Thanx in advance
    >
    > Regards,
    > --
    > S.Sundararajan
    Dale Preston, Apr 13, 2005
    #5
  6. Sundararajan

    Sundararajan Guest

    Hi,

    however in this the registerstartupscript methog requires the script be
    passed as string. but i have it a separate file and i want to refer to that
    file by using the url. is that possible. or should i read from the url and
    convert it into a string and then use this method.

    regards,
    sundararajan.s

    "Kannan.V [MCSD.net]" wrote:

    > hi,
    >
    > Add an include line to link the js file to your page,
    > This can be done using Page.Registerstartupscript("Key","Script")
    > Once the js file is linked with ur page, you can assign the methods in the
    > js file to the control events.
    > Ex: btnButton.Attributes.Add("OnClick", "YourJSfunction");
    >
    > play around with this and you'll get to know a lot more...
    >
    > Regds
    > Kannan.V
    >
    > "Sundararajan" wrote:
    >
    > > Dear Folks,
    > >
    > > I am developing a server control as a composite control. I need to
    > > associate some javascripts with the individual controls of the composite
    > > control.
    > > I have the javascrips in a separate .js file. how can i associate the
    > > functions in .js file with the server controls.
    > >
    > > Thanx in advance
    > >
    > > Regards,
    > > --
    > > S.Sundararajan
    Sundararajan, Apr 13, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stu
    Replies:
    2
    Views:
    1,729
    Daniel TIZON
    Dec 16, 2005
  2. Jan Danielsson
    Replies:
    8
    Views:
    613
    Mike Meyer
    Jul 22, 2005
  3. Jp Calderone
    Replies:
    0
    Views:
    446
    Jp Calderone
    Jul 21, 2005
  4. davidj411
    Replies:
    0
    Views:
    483
    davidj411
    Jun 27, 2008
  5. Replies:
    13
    Views:
    517
    Anno Siegel
    Sep 10, 2007
Loading...

Share This Page