When does that script get called? Is it called automatically?
Main Topics
Browse All TopicsI have some data that is grouped into categories which are being shown/hid using SPAN and JAVASCRIPT. This part works fine. However, I need some way to show a SPAN (i.e. the group people are most interested in) by default.
Normally, I'd set the OnLoad attribute of the BODY tag to call a JAVASCRIPT function which shows the SPAN I want.
But, I'm adding 2 complexities to it:
1) I'm using UserControls (which don't have a BODY tag)
2) I'd like to programatically set which SPAN is shown.
Is there a way I can tell a UserControl to run a JAVASCRIPT function when it gets loaded which will solve #1. I'm assuming that once I know how to do that, it will be easy to set the SPAN as an input paramter in my Code-Behind for the function which will achive #2
Also, I've found that there is a lot of things I want to do which require mixing C#/Code-Behinds and JAVASCRIPT. Is there a website which details how to have one interact with the other?
Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The Page_Load of user control is called after the Page_Load of the page hosting it. So this would generate javascript code somewhere near the user control tag. And this is up to you to write anything in that piece of code. So the example that I gave would generate
<script>alert('Hello')</sc
in the final HTML. So an alert would come as soon as the page is rendered.
Business Accounts
Answer for Membership
by: amit_gPosted on 2005-01-25 at 14:03:04ID: 13137034
Do this in Page_Load of user control ...
("MyScript ID", "<script>alert('Hello')</s cript>")
Page.RegisterStartupScript
This would basically call alert function. Now you could have any script here. You could build script at runtime.