Solved

ASPX, ASCX and JavaScript Interrelationships

Posted on 2013-05-25
3
408 Views
Last Modified: 2013-06-04
Greetings;

I have 3 sets of entities as follows:

1. Two dozen ASPX pages which incorporate a common header
2. A stored JavaScript source which references controls in a #include in the ASPX pages
3. A #include containing HTML defining the header presentation.

Using Visual Studio 2010 Pro, #include statements are not processed in order for me to see the entire marked up page when in design mode for an ASPX page.

If I try and place the #include HTML in an ASCX user control, the JavaScript returns an error indicating the control I'm attempting to access (which is defined in the ASCX user control) in the JavaScript does not exist.

I also attempted to include the JavaScript with the ASCX page which also resulted in JavaScript errors.

I attempted to create a Master page, however, the JavaScript gave me a similar error after creating a new ASPX page using the Master page. The Master page included the common elements of each page including the #include HTML and the JavaScript.

Is there a way using an ASCX user control to have the #include HTML and subsequently have the JavaScript (referenced in each ASPX page) reference controls within the ASCX file?


Much thanks ... David
0
Comment
Question by:David Bach
  • 2
3 Comments
 
LVL 18

Expert Comment

by:Gary Davis
Comment Utility
You did not include any code to review or specific error messages to help resolve this question. However, #include seems to be from the old .asp (pre-dotNet) days. Including HTML would be done by using ascx user controls which could emit HTML in various ways (inline HTML, reading a template or "include" file, etc).

As far as having JavaScript interact with controls within the ascx user control, it would actually be working with the Html controls, DOM, or perhaps jQuery objects on the client side and not the server controls.

Gary Davis
0
 

Accepted Solution

by:
David Bach earned 0 total points
Comment Utility
Greetings;

My apologies for not responding sooner. I found a solution and proved it to work by putting it into practice.

Using Master Pages I am able to encapsulate the JavaScript I have into an external .js file, and, place the boiler plate HTML and code behind code into the Master Page. This resolves the redundancy of having this same code in every page. I needed to research how to register JavaScript code via VB in order to ensure the generated ID names were used in the JavaScript function.

Thank you ... David
0
 

Author Closing Comment

by:David Bach
Comment Utility
Greetings;

I did not initially provide enough data for the question to be resolved. This was an assumption on my part and not intentional.

Between the time I posted the question and now, I found an acceptable solution.


Thank you ... David
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now