Re: TRICK: methods in ASPX pages with <%%> code blocks



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
>


.



Relevant Pages

  • Error in OLEDB Transaction
    ... >I am using transaction in aspx code ... > myCon .Open = GetConString() ... >What may be the reason for that message ...
    (microsoft.public.dotnet.general)
  • Re: What is "this" ?
    ... Is there a very good reason to use "this" ... John ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Firefox - tip for printing pages
    ... but for some reason the Print to File radio button ... George ... Prev by Date: ...
    (comp.sys.acorn.apps)
  • Why does the text turn vertical when I reduce the drawing scale?
    ... In addtion, when I set the select protection to true, you can still select a ... Any reason why, and what cen be done to make a shape completely ... Prev by Date: ...
    (microsoft.public.visio.general)
  • making a form field remember
    ... Each of the 4 fields has a different sub before update function with ... this line of code within the form but for some reason only two of them ... sushi155Posted from http://www.pcreview.co.uk/ newsgroup access ... Prev by Date: ...
    (microsoft.public.access.formscoding)

Loading