Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 27th, 2006, 02:15 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Order of Code Generation Problem

Ok, I'm having some issues with the order of code generation with ASP and C#.

basically I have some code set up as follows:
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="myinc.aspx.cs" Inherits="myinc"%>

<HTML>
<HEAD>
<TITLE>MY PAGE</TITLE>
<script language="JavaScript" type="text/javascript" src="scripts/core1.js"></script>
<script language="JavaScript" type="text/javascript" src="scripts/core2.js"></script>
<script language="C#" runat="server">
    void Page_Load(object Source, EventArgs e)
    {
        CreateContent();
    }
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
My problem is that upon viewing the generated page source, all the HTML generated by CreateContent() is listed before anything else on the page. I need it to be generated after all the Javascript definitions (IE in the place that I put it in the .aspx file). Anyone have a clue what's happening?
 
Old July 5th, 2006, 09:48 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your content is being wrote to the page before everything else because the Page_Load event is processed before you actual page is loaded by the client. What you could do is something like this:

[HTML code]
       <% CreateContent() %>
[/HTML Code]

So basically place that call inline with your code and the HTML will be rendered in that spot, just make sure the method CreateContent is declared with, at least, a Protected identifier. (To be truthful i have had spoty luck using Protected and have ended up using Public alot when i needed to do this)

Alternatively you could set up a panel on your page and then on your backend use an HTMLWriter, Render it, and add it to the panel.

HtH.

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Report Generation Problem lushh Access VBA 2 September 5th, 2006 07:16 AM
JSP Code Generation using XML ? javadude XSLT 0 June 9th, 2005 07:50 AM
SQL "Order By" problem bear88 SQL Language 3 April 13th, 2005 10:45 AM
Visio Templates for UML Code Generation location Imar General .NET 1 March 6th, 2005 12:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.