设计页面:我正在使用母版页&更新面板&脚本管理器
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table width="100%" cellpadding="8" cellspacing="8">
<tr>
<td style="width: 11.11%;" align="right">
<asp:Label ID="Label10" runat="server" Text="Total Leave" CssClass="lab"></asp:Label>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txttotsick" runat="server" Width="100px" CssClass="textbox" AutoPostBack="true"
ontextchanged="txttotsick_TextChanged"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txttotvacation" runat="server" Width="100px" AutoPostBack="true"
CssClass="textbox" ontextchanged="txttotvacation_TextChanged"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txttotpaternity" runat="server" Width="100px" AutoPostBack="true"
CssClass="textbox" ontextchanged="txttotpaternity_TextChanged"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txttotMaternity" runat="server" Width="100px" AutoPostBack="true"
CssClass="textbox" ontextchanged="txttotMaternity_TextChanged"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txttotServiceIncentive" runat="server" Width="100px" AutoPostBack="true"
CssClass="textbox" ontextchanged="txttotServiceIncentive_TextChanged"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txttotsoloparent" runat="server" Width="100px" AutoPostBack="true"
CssClass="textbox" ontextchanged="txttotsoloparent_TextChanged"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txttotBirthday" runat="server" Width="100px" AutoPostBack="true"
CssClass="textbox" ontextchanged="txttotBirthday_TextChanged"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txttotBreavment" runat="server" Width="100px" AutoPostBack="true"
CssClass="textbox" ontextchanged="txttotBreavment_TextChanged"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 11.11%;" align="right">
<asp:Label ID="Label12" runat="server" Text="Balance Leave" CssClass="lab"></asp:Label>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txtbalsick" runat="server" Width="100px" CssClass="textbox"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txtbalvoacation" runat="server" Width="100px" CssClass="textbox"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txtbalpartinity" runat="server" Width="100px" CssClass="textbox"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txtbalmarternity" runat="server" Width="100px" CssClass="textbox"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txtbalserviceincentive" runat="server" Width="100px" CssClass="textbox"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txtbalsoloparent" runat="server" Width="100px" CssClass="textbox"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txtbalbirthday" runat="server" Width="100px" CssClass="textbox"></asp:TextBox>
</td>
<td style="width: 11.11%;" align="right">
<asp:TextBox ID="txtbalbreavement" runat="server" Width="100px" CssClass="textbox"></asp:TextBox>
</td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
编码页面:我在Textbox TextChanged事件期间进行了一些计算......
protected void txttotsick_TextChanged(object sender, EventArgs e)
{
try
{
if (txttotsick.Text.Trim() != string.Empty)
{
txtbalsick.Text = (Convert.ToInt32(txttotsick.Text.Trim()) - Convert.ToInt32(txtconSick.Text.Trim())).ToString();
}
else
{
txtbalsick.Text = (0 - Convert.ToInt32(txtconSick.Text.Trim())).ToString();
}
txttotalbalanceday.Text = (Convert.ToInt32(txtbalsick.Text.Trim()) + Convert.ToInt32(txtbalvoacation.Text.Trim()) + Convert.ToInt32(txtbalpartinity.Text.Trim()) + Convert.ToInt32(txtbalmarternity.Text.Trim()) + Convert.ToInt32(txtbalserviceincentive.Text.Trim()) + Convert.ToInt32(txtbalsoloparent.Text.Trim()) + Convert.ToInt32(txtbalbirthday.Text.Trim()) + Convert.ToInt32(txtbalbreavement.Text.Trim())).ToString();
}
catch (Exception ex)
{
throw ex;
}
}
在文本更改事件后,控件转到页面的第一个文本框...如何才能正确执行... 感谢...