By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,515 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,515 IT Pros & Developers. It's quick & easy.

Programmatic production of HTML...

P: n/a

Hi folks,

Just wondering how I can call a function in a code behind file from within
the body of the ASPX file.

The old ASP way was to use <%= MyFunction() %>, but that doesn't seem to
work anymore...Thus :

<body MS_POSITIONING="GridLayout">
<form id="frmAssessmentPrint" method="post" runat="server">
</form>
<% MyFunction() %>
</body>

I've tried a straight FunctionCall(), classname.FunctionCall() and
parent.FunctionCall().

I'm pretty certain that I've seen it somewhere in the help system or the
MSDN docs, but can't recall where. Is it possible at all from a code that's
in a seperate .VB code behind file??

To give you some background I'm writing a report where I'm parsing my data
into HTML. At the moment I'm feeding the output through the page_load event
using the reponse.write method, but it's putting the HTML before the <HTML>
tag. I've tried other events, but with no success. It's working OK like
this, but I suspect browsers other than IE will have problems with it.
Also, it's just generally useful to know...

Thanks in advance....Paul
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi, Paul Mason,

How about adding a System.Web.UI.WebControls.Literal inside the form and
setting its Text property in the Page_Load handler? Is it limited that the
html you want to output should be outside the form?

Also, you can do it like this:

<body MS_POSITIONING="GridLayout">
<form id="frmAssessmentPrint" method="post" runat="server">
</form>
<%
Response.Write(MyFunction())
%>
</body>

Just add a semicolon (;) at the end of the line if you are using C#.
MyFunction() should be member of the class for the page. It can be also
static (in VB shared).

Greetings
Martin
"Paul Mason" <ma****@trials.bham.ac.uk> wrote in message
news:#u**************@tk2msftngp13.phx.gbl...

Hi folks,

Just wondering how I can call a function in a code behind file from within
the body of the ASPX file.

The old ASP way was to use <%= MyFunction() %>, but that doesn't seem to
work anymore...Thus :

<body MS_POSITIONING="GridLayout">
<form id="frmAssessmentPrint" method="post" runat="server">
</form>
<% MyFunction() %>
</body>

I've tried a straight FunctionCall(), classname.FunctionCall() and
parent.FunctionCall().

I'm pretty certain that I've seen it somewhere in the help system or the
MSDN docs, but can't recall where. Is it possible at all from a code that's in a seperate .VB code behind file??

To give you some background I'm writing a report where I'm parsing my data
into HTML. At the moment I'm feeding the output through the page_load event using the reponse.write method, but it's putting the HTML before the <HTML> tag. I've tried other events, but with no success. It's working OK like
this, but I suspect browsers other than IE will have problems with it.
Also, it's just generally useful to know...

Thanks in advance....Paul


Nov 18 '05 #2

P: n/a
You can still do this - <%= MyFunction%>, but you have to declare the
function in the codebehind as "Protected" in order to see it from the page.

"Paul Mason" <ma****@trials.bham.ac.uk> wrote in message
news:%2********************@tk2msftngp13.phx.gbl.. .

Hi folks,

Just wondering how I can call a function in a code behind file from within
the body of the ASPX file.

The old ASP way was to use <%= MyFunction() %>, but that doesn't seem to
work anymore...Thus :

<body MS_POSITIONING="GridLayout">
<form id="frmAssessmentPrint" method="post" runat="server">
</form>
<% MyFunction() %>
</body>

I've tried a straight FunctionCall(), classname.FunctionCall() and
parent.FunctionCall().

I'm pretty certain that I've seen it somewhere in the help system or the
MSDN docs, but can't recall where. Is it possible at all from a code that's in a seperate .VB code behind file??

To give you some background I'm writing a report where I'm parsing my data
into HTML. At the moment I'm feeding the output through the page_load event using the reponse.write method, but it's putting the HTML before the <HTML> tag. I've tried other events, but with no success. It's working OK like
this, but I suspect browsers other than IE will have problems with it.
Also, it's just generally useful to know...

Thanks in advance....Paul

Nov 18 '05 #3

P: n/a

Thanks. I didn't realise what the literal control was.

Thanks also to Rick for letting me know it had to be protected..

P

"Martin Dechev" <de*******@hotmail.com> wrote in message
news:Ox**************@tk2msftngp13.phx.gbl...
Hi, Paul Mason,

How about adding a System.Web.UI.WebControls.Literal inside the form and
setting its Text property in the Page_Load handler? Is it limited that the
html you want to output should be outside the form?

Also, you can do it like this:

<body MS_POSITIONING="GridLayout">
<form id="frmAssessmentPrint" method="post" runat="server">
</form>
<%
Response.Write(MyFunction())
%>
</body>

Just add a semicolon (;) at the end of the line if you are using C#.
MyFunction() should be member of the class for the page. It can be also
static (in VB shared).

Greetings
Martin
"Paul Mason" <ma****@trials.bham.ac.uk> wrote in message
news:#u**************@tk2msftngp13.phx.gbl...

Hi folks,

Just wondering how I can call a function in a code behind file from within the body of the ASPX file.

The old ASP way was to use <%= MyFunction() %>, but that doesn't seem to
work anymore...Thus :

<body MS_POSITIONING="GridLayout">
<form id="frmAssessmentPrint" method="post" runat="server">
</form>
<% MyFunction() %>
</body>

I've tried a straight FunctionCall(), classname.FunctionCall() and
parent.FunctionCall().

I'm pretty certain that I've seen it somewhere in the help system or the
MSDN docs, but can't recall where. Is it possible at all from a code

that's
in a seperate .VB code behind file??

To give you some background I'm writing a report where I'm parsing my data into HTML. At the moment I'm feeding the output through the page_load

event
using the reponse.write method, but it's putting the HTML before the

<HTML>
tag. I've tried other events, but with no success. It's working OK like this, but I suspect browsers other than IE will have problems with it.
Also, it's just generally useful to know...

Thanks in advance....Paul

Nov 18 '05 #4

P: n/a
you can use dataBinding
int aspx file :
CustomerID :<%# CustomerID %>

in aspx.cs code file:
page_load()
{
this.DataBind();
}

"Paul Mason" <ma****@trials.bham.ac.uk> дϢ
news:#u**************@tk2msftngp13.phx.gbl...

Hi folks,

Just wondering how I can call a function in a code behind file from within
the body of the ASPX file.

The old ASP way was to use <%= MyFunction() %>, but that doesn't seem to
work anymore...Thus :

<body MS_POSITIONING="GridLayout">
<form id="frmAssessmentPrint" method="post" runat="server">
</form>
<% MyFunction() %>
</body>

I've tried a straight FunctionCall(), classname.FunctionCall() and
parent.FunctionCall().

I'm pretty certain that I've seen it somewhere in the help system or the
MSDN docs, but can't recall where. Is it possible at all from a code that's in a seperate .VB code behind file??

To give you some background I'm writing a report where I'm parsing my data
into HTML. At the moment I'm feeding the output through the page_load event using the reponse.write method, but it's putting the HTML before the <HTML> tag. I've tried other events, but with no success. It's working OK like
this, but I suspect browsers other than IE will have problems with it.
Also, it's just generally useful to know...

Thanks in advance....Paul

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.