ASP.Net/HTML Control/TextBox — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 11:53, 26 мая 2010

HTML Control: Input (C#)

<%@ Page Language="C#" %>
<html>
<script runat=server>
protected void Page_Load(object src, EventArgs e)
{
  if (IsPostBack)
  {
    int op1 = int.Parse(_op.Value);
    int op2 = int.Parse(_sum.InnerText);
    _sum.InnerText = (op1+op2).ToString();
  }
}
</script>
<body>
  <form runat=server>
    <h2>ASP.NET accumulator page</h2>
    <input size=2 type=text id=_op runat=server/>
    Sum:<span id=_sum runat=server>0</span>
    <p>
     <input type=submit value="Add" />
    </p>
  </form>
</body>
</html>



Using an HTML Form Control: get value in input box and display (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub SubmitBtn_Click(Source As Object, E as EventArgs)
    MyMessage.InnerHTML = "Hello " & YourName.Value
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Using an HMTLForm Control</TITLE>
</HEAD>
<BODY>
<form 
    runat="server"
    id="MyForm"
    method="Post"    
    disabled="False"
    visible="True"
>
<Span
    id="MyMessage"
    runat=server
>
</Span>    
<BR>    
Name: <BR>
<Input
    id="YourName"
    runat="server"
    type="text"
>
<BR>
<BR><BR>
<button 
    id="Button1"
    runat="server"
    onserverclick="SubmitBtn_Click" 
>
Submit
</button>
</Form>
</BODY>
</HTML>