Click here to Skip to main content
15,895,084 members
Articles / Web Development / HTML

ASP EasyForm: ASP.NET-like forms in two minutes

Rate me:
Please Sign up or sign in to vote.
4.30/5 (7 votes)
27 Nov 2008CPOL7 min read 28.8K   171   18  
EasyForm allows you to create ASP.NET-like forms, with state keeping and server side event handling
<!--#include file="inc/EasyForm.asp" -->

 <%
 ' --- Declarations ---
 EF.DimVar "email","text"
 EF.DimVar "Password","password"
 EF.DimVar "newarticles","checkbox"
 EF.DimVar "updatedarticles","checkbox"
 EF.DimVar "role","select"
 EF.DimVar "platform","select"
 EF.DimVar "mailformat","radio"
 EF.DimVar "notes","textarea"

 
 
' --- Call to init sub ---
 EF.init
 
' --- Handler for on load 
sub EF_onLoad()
  if EF.IsFirstLoad then    
    email.value = "your mail here"
    mailformat.value = "HTML"
    platform.value = "WIN,NET"
    newarticles.value = "1"
  end if
  
end sub

 
 %>
  
 <html>
 <head>
    <style>
        body,td, select, input { 
            font-family:tahoma,verdana;
            font-size:12px;
        }

        .comment { color:green; }
    </style>
 </head>
<body>

 <div class=comment>
     The form now lives and is able to "remember" all user inputs.
     The rules are simple:
     <ul>
        <li>- Include EasyForm.asp</li>
        <li>- Use EF.DimVar to declare the EasyForms variables that will be attached to the controls </li>
        <li>- Call the EF.init method</li>
        <li>- Add the EF_onLoad sub containing the initialization code. Use <i>value</i> property to get and set the value of an EasyForm variable</li>
        <li>- Attach each control to its variable using the <i>Bind</i> and/or <i>AddOption</i> methods of the variable</li>
     </ul>
 </div>
 <br />
 
 
 <form method="post">
    <table>
        <tr>
            <td valign=top align=right>
                <span>Email</span>          <br /><br />
                <span>Password</span>       <br /><br /><br />   
                <span>Topics</span>         <br /><br /><br />  
                <span>Role</span>           <br /><br /><br />
                <span>Platform</span>       <br /><br /><br /><br />
                <span>Email format</span>   <br /><br /><br /><br /><br />
                <span>Notes</span>          <br />
                
            </td>
            <td valign=top>
                <input type="text" <%Email.Bind%> />                                <br />
                <input type="password" <%Password.Bind%> />                         <br /><br />
                <input type="checkbox" <%newarticles.Bind%> />New Articles      <br />
                <input type="checkbox" <%updatedarticles.Bind%> />Updated Articles  <br /><br />
                 <select <%role.Bind%> >
	                <option <%role.AddOption "noselection" %> >Select role...</option>
	                <option <%role.AddOption "CS"%>>C# developer</option>
	                <option <%role.AddOption "CPP"%>>C++ developer</option>
	                <option <%role.AddOption "WEB"%>>Web developer</option>
                 </select>
                                                                                    <br /><br />
                
                 <select <%platform.bind%> size=3 multiple>
	                <option <%platform.AddOption "WIN"%>>Windows</option>
	                <option <%platform.AddOption "NET"%>>.Net</option>
	                <option <%platform.AddOption "MOB"%>>Mobile</option>
                 </select>
                                                                                    <br /><br />
                <input type=radio <%mailformat.AddOption "HTML"%>>Html	            <br />
                <input type=radio <%mailformat.AddOption "TEXT"%>>Text              <br /><br />
	            
                <textarea cols=20 rows=5 <%Notes.Bind%>><%=Notes.value%></textarea> <br />
            
                <input type="submit" value="submit"/>
                
                <a href="sample1.asp">reset</a>
                
            </td>
        </tr>
    </table>
    
    <%EF.EndForm%>
 </form> 

</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
Italy Italy
I'm a graduate in Computer Science.
I work with Metatrader MQL4,MQL5 / C# / Asp.Net / Windows Forms / SQL Server / Access / VBA / HTML / CSS / Javascript / classic C/C++.


I also like writing songs and playing around with my band Diversamente Rossi.
This is the video of the song Un'altra estate from the album L'immobile disegno.



"Short code, good code"

Comments and Discussions