Solved

ASPX, ASCX and JavaScript Interrelationships

Posted on 2013-05-25
3
412 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
ID: 39197716
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
ID: 39208685
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
ID: 39218404
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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 …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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