J
John Rivers
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
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