To create more active server pages as done in the first example, it is necessary to add code and reference elements of a page. The most simple way is to add a script section in the ‘index.aspx’ source. It may be surprising to see that the event handler is defined as a member function of a System.Web.UI.Page class definition. In the next example we add an event handler for a button click. As usual you need a ‘web.config’ file and a subdirectory bin with with FSharp.Compiler.CodeDom.dll, see in the first example how to do it, the source file in our example should be named index.aspx: <%@ Page Language="F#" Trace="false" %><script runat="server">
member page.mybutton_Click((sender:obj), (e:EventArgs)) =
page.mybutton.Text <- "Clicked"
</script><html>
<body>
<h2>ASP.NET Simple Web Forms Demo</h2><form method="post" runat="server">
button: <asp:button id="mybutton" runat="server" Text="Click Me"
OnClick="mybutton_Click"/>
</form></body>
</html>When starting the web server xsp2 in the directory of your source file you should see the following content in your web browser when pointing it to ‘http://localhost:8080′ Read more: 2#4u
member page.mybutton_Click((sender:obj), (e:EventArgs)) =
page.mybutton.Text <- "Clicked"
</script><html>
<body>
<h2>ASP.NET Simple Web Forms Demo</h2><form method="post" runat="server">
button: <asp:button id="mybutton" runat="server" Text="Click Me"
OnClick="mybutton_Click"/>
</form></body>
</html>When starting the web server xsp2 in the directory of your source file you should see the following content in your web browser when pointing it to ‘http://localhost:8080′ Read more: 2#4u
0 comments:
Post a Comment