Arc Forumnew | comments | leaders | submitlogin
4 points by amund 6136 days ago | link | parent

Shorter but non-idiomatic C#/ASP.NET:

    <%@ Page Language="C#" %>
    <html>
    <head>
    <title>Said</title>
    </head>
    <body>
        <form id="form" runat="server">
            <% if (!IsPostBack) { %>
                <input name="foo" />
                <input type="submit" />
            <% } else if (Request.Form["foo"] != null) {
                Session["foo"] = Request.Form["foo"]; %>
                <a href="javascript:form.submit()">click here</a>
            <% } else { %>
                you said: <%=Session["foo"]%>
            <% } %>
        </form>
     </body>
    </html>


3 points by brentb 5865 days ago | link

Shorter still, but exactly the same idea:

<%@ Page Language="C#" %> <form id="f" runat="server"> <% var v = Request.Form["x"]; if (!IsPostBack) { %> <input name="x" /><input type="submit" /> <% } else if (v != null) { Session["x"] = v; %> <a href="javascript:f.submit()">click here</a> <% } else { %>you said: <%=Session["x"]%><% } %></form>

-----