跳转至内容

ASP.NET/添加一些交互性

来自维基教科书,开放世界开放书籍

要么

<%@ Page Language="VB" %>

<%@ Page Language="C#" %>
<html>
 <head>
   <title>Testing Interactivity</title>

VB.Net 代码

   <script runat="server" language="vbscript">
     ' ASP.NET page code goes here
     Sub Page_Load()
       'On Page Load Run this code
     End Sub
     Sub submit_Click()
       output.Text = "'" & input.Text & "' (" & input.Text.Length & " characters)"
     End Sub
   </script>

C# 代码

   <script runat="server" language="c#">
     // ASP.NET page code goes here
     void Page_Load(object sender, EventArgs e){
        // On Page Load Run this code
     }
     void submit_Click(object sender, EventArgs e){
        output.Text = "'" + input.Text + "' (" + input.Text.Length + " characters)";
     }
   </script>
 </head>
 <body>
   <form runat="server">
     <asp:textbox id="input" runat="server"/>
     <asp:literal id="output" runat="server"/>
     <asp:button id="submit" runat="server" text="show details" OnClick="submit_Click"/>
   </form> 
 </body>
</html>
华夏公益教科书