Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

ASPX, ASCX and JavaScript Interrelationships

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
David Bach
Asked:
David Bach
  • 2
1 Solution
 
Gary DavisDir Internet SvcsCommented:
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
 
David BachAuthor Commented:
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
 
David BachAuthor Commented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now