Solved

ASPX, ASCX and JavaScript Interrelationships

Posted on 2013-05-25
3
416 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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