Following code can help you in starting. You can use it and make the required changes. Hope it helps you.
In the ASPX file, set the textbox property to
AutoPostBack
to
true.
<![CDATA[
<asp:content id="HeaderContent" runat="server" contentplaceholderid="HeadContent" xmlns:asp="#unknown">
</asp:content>
<asp:content id="BodyContent" runat="server" contentplaceholderid="MainContent" xmlns:asp="#unknown">
<table>
<tr>
<td>
<asp:textbox runat="server" id="TextBox1" autopostback="true">
</asp:textbox>
</td>
</tr>
<tr>
<td>
<asp:button runat="server" id="SaveBtn" text="Save" onclick="SaveBtn_Click" />
</td>
</tr>
</table>
</asp:content>
In the codebehind, on
Save
button click, increment the value.
public partial class _Default : System.Web.UI.Page
{
static int i = 1;
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = i.ToString();
}
protected void SaveBtn_Click(object sender, EventArgs e)
{
i++;
}
}