|
-
Aug 7th, 2002, 11:07 AM
#1
Thread Starter
Hyperactive Member
vb .net (asp .net) app... response.write
I feel this falls into the 'stupid question' category, but the time has come that I must ask it.
I have this code from my vb .net (asp .net) application (created in visual studio .net)
VB Code:
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Response.Write("<table><tr><td>Why does this show up above the html tags</td></tr></table>")
End Sub
End Class
Why does my response.write show get written above every other tag on the page... like this:
[Results]
Code:
<table><tr><td>Why does this show up above the other tags?</td></tr></table>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE" value="dDwtMTI3OTMzNDM4NDs7PuIeAj03w2/SZE+efTMFhqIXJ3Ap" />
</form>
</body>
</HTML>
How do I make the stuff from my response.write get written inside of the <body> tags on the resulting page????
My guess is that I need to stick some 'runat=server' stuff somewhere, but I don't know where.
thanks!
-
Aug 7th, 2002, 11:12 AM
#2
use placeholder control then you can set its value in page load
stick this where you need it
<asp:PlaceHolder id="myPlace" runat="server"/>
in page load, just say
myPlace.Text = "<table><tr><td>Why does this show up above the html tags</td></tr></table>"
-
Aug 7th, 2002, 11:16 AM
#3
Thread Starter
Hyperactive Member
aha. Sounds good... now for the massive restructuring on all of my projects 
*doh*
thanks again.
-
Aug 7th, 2002, 11:24 AM
#4
your welcome.
ASP .NET can be a bit tricky a times with knowing what controls to use to avoid using inline asp tags <% %>
-
Aug 7th, 2002, 11:30 AM
#5
Thread Starter
Hyperactive Member
hmm... where do I put this:
<asp:PlaceHolder id="myPlace" runat="server"/>
in the aspx.vb code?
Just to be clear, the code that I posted second in my original post (labeled "results") is what I get when I 'view source' after the WebForm1.aspx is run.
-
Aug 7th, 2002, 11:33 AM
#6
you put it where the html should appear.
-
Aug 7th, 2002, 11:38 AM
#7
Thread Starter
Hyperactive Member
Sorry, I'm not gettin' it.
Here's my aspx.vb code again:
VB Code:
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
<asp:PlaceHolder id="myPlace" runat="server"/>
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myPlace.Text = "<table><tr><td>Why does this show up above the html tags</td></tr></table>"
End Sub
End Class
Everywhere I put '<asp:PlaceHolder id="myPlace" runat="server"/>' in that code, it has problems with it. I'm confused I guess.
-
Aug 7th, 2002, 11:40 AM
#8
no you dont stick it in subs, you put it in the actual html code area
for example
<html>
<body>
<asp:PlaceHolder blah blah blah..../>
</body>
</html>
This is called a web form control. You may want to read up on them as they are VERY helpful and powerful.
-
Aug 7th, 2002, 11:42 AM
#9
Member
I think the problem is the load is the first thign run. How to fix i am nto sure, haven't looked into it yet.
did youcreate the page load event? You shoudl move that code to another place, out side of the load.
I will experiment when ido a fresh xp/.net install and let you knwo my results
-------------------------------
StupidMonkee
-
Aug 7th, 2002, 11:47 AM
#10
Thread Starter
Hyperactive Member
Oh... I just noticed something that I haven't seen before. I've always double clicked the webform when it shows up in vs .net. I just right clicked on the webform and clicked on 'View HTML Source'.
Now I see where I need to put '<asp:PlaceHolder id="myPlace" runat="server"/>'.
I didn't know that I had access to the html source of the webform.aspx. Until just now, I had only seen it by clicking view source in ie after the aspx was run.
Thanks a ton for all of your quick replies!
-
Aug 7th, 2002, 11:49 AM
#11
you welcome, and just so you dont get confused, after putting in that <asp;PlaceHolder, if you then view the requested pages source, you will not see that <asp:Placeholder. it will be replaced with the html you set as the .Text property.
Just some FYI to help you better understand how Web Form controls work.
-
Aug 7th, 2002, 11:50 AM
#12
Thread Starter
Hyperactive Member
-
Aug 7th, 2002, 12:08 PM
#13
Thread Starter
Hyperactive Member
k... one more question. In the html portion of WebForm1.aspx, I have this:
Code:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="example1.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:PlaceHolder id="myPlace" runat="server"/>
</form>
</body>
</HTML>
In WebForm1.aspx.vb, I have this:
VB Code:
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Says "Name 'myPlace' is not decalred.
myPlace.Text = "<table><tr><td>Why does this show up above the html tags</td></tr></table>"
End Sub
End Class
It says that myPlace is not declared. Should this be happening? What do I declare it as?
-
Aug 7th, 2002, 12:17 PM
#14
oh you are using codebehind..
right below this line
Inherits System.Web.UI.Page
put
Public myPlace As System.Web.UI.WebControls.PlaceHolder
-
Aug 7th, 2002, 12:32 PM
#15
Thread Starter
Hyperactive Member
hmm... two problems now...
one is here:
Public myPlace As System.Web.UI.WebControls.PlaceHolder
myPlace is underlined, and gives error:
'myPlace' is already declared as 'Protected Dim WithEvents myPlace As System.Web.UI.WebControls.PlaceHolder' in this class
The other is here:
myPlace.Text
that ^ is underlined and gives error:
'Text' is not a member of 'System.Web.UI.WebControls.PlaceHolder'
-
Aug 7th, 2002, 12:40 PM
#16
oopss..i fudges up..I gave you the wrong control name..change PlaceHolder to Literal...
That should do it..I hope.
-
Aug 7th, 2002, 12:49 PM
#17
Thread Starter
Hyperactive Member
TADDAAA....
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE" value="dDwtMjM2MzU3MjA2O3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDE+Oz47bDx0PHA8bDxUZXh0Oz47bDxcPHRhYmxlXD5cPHRyXD5cPHRkXD5XaHkgZG9lcyB0aGlzIHNob3cgdXAgYWJvdmUgdGhlIGh0bWwgdGFnc1w8L3RkXD5cPC90clw+XDwvdGFibGVcPjs+Pjs7Pjs+Pjs+Pjs+BONwb6kb293q1honbKd2Srrv0bQ=" />
<table><tr><td>Why does this show up above the html tags</td></tr></table>
</form>
</body>
</HTML>
Thanks a ton man . That seems to have done the trick.
-
Aug 7th, 2002, 12:50 PM
#18
w00t!
-
Aug 7th, 2002, 01:06 PM
#19
Thread Starter
Hyperactive Member
*resolved* :) vb .net (asp .net) app...
*resolved*
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|