Re: TRICK: methods in ASPX pages with <%%> code blocks
- From: "Marina" <someone@xxxxxxxxxx>
- Date: Tue, 23 Aug 2005 10:11:21 -0400
Who says you can't have methods in the page?
Just put your methods in <script runat="server"></server"
And as someone mentioned, even though you can do this, you shouldn't. There
is no reason you can't put it in a code behind file, or in a class library
DLL.
"John Rivers" <first10@xxxxxxxxxxxxxx> wrote in message
news:1124802159.732594.264450@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hello,
>
> What good reason there is for not allowing methods in ASPX pages I
> can't imagine, but here is how to get around that limitation:
>
> (START)
> <body MS_POSITIONING="FlowLayout">
>
> <form id="Form1" method="post" runat="server">
> <%
> MyMethod(__output);
> %>
> </form>
> </body>
> </html>
> <%
> }
> void MyMethod(System.Web.UI.HtmlTextWriter __output) {
> %><input type="text" name="Name" value="some html"/><%
> %>
> (END)
>
> how this works:
>
> ASP.NET takes your ASPX code and inserts it into a hidden Render
> method that takes HtmlTextWriter as an argument
>
> we use "}" to close the current render method
> then declare a method that takes the same argument
> we don't need to put a closing brace because ASP.NET will
> do that for us
>
.
- Follow-Ups:
- Re: TRICK: methods in ASPX pages with <%%> code blocks
- From: tom pester
- Re: TRICK: methods in ASPX pages with <%%> code blocks
- References:
- TRICK: methods in ASPX pages with <%%> code blocks
- From: John Rivers
- TRICK: methods in ASPX pages with <%%> code blocks
- Prev by Date: How to reload the webpage
- Next by Date: How ro get the width of the DIV?
- Previous by thread: Re: TRICK: methods in ASPX pages with <%%> code blocks
- Next by thread: Re: TRICK: methods in ASPX pages with <%%> code blocks
- Index(es):
Relevant Pages
|
Loading