ASP.NET Tutorial/Data Binding/TextBox

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

DataBind TextBox

<script runat="server" language="C#">
protected void Page_Load(object o, EventArgs e) {
    if(IsPostBack) {
       Page.DataBind();
    }
}
</script>
<form runat="server">
Add two numbers:
<asp:TextBox runat="server" id="operand1" /> + 
<asp:TextBox runat="server" id="operand2" /><br />
<asp:Button type="submit" runat="server" Text="Submit" /><br />
The DataBound result = <%# Int32.Parse(operand1.Text) + Int32.Parse(operand2.Text) %>
</form>