来源:网络 | 2013-4-20 | (有1684人读过)
<asp:TextBox ID="CompanyName" runat="server" AutoPostBack="True"
ontextchanged="CompanyName_TextChanged"></asp:TextBox>
</td>
<td width="238">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="LblCheckName" runat="server" Font-Size="12px"
ForeColor="#FF3300" Visible="False"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="CompanyName" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
正在检测名称..
</ProgressTemplate>
</asp:UpdateProgress>
/// <summary>
/// ajax控件检测
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void CompanyName_TextChanged(object sender, EventArgs e)
{
string cpName = this.CompanyName.Text.Trim();
if (chekCompanyName(cpName))
{
LblCheckName.Text = "允许";
this.LblCheckName.Visible = true;
this.Button1.Enabled = true;
}
else
{
LblCheckName.Text = "数据库中不存在该公司,不允许添加";
this.LblCheckName.Visible = true;
this.Button1.Enabled = false;
}
}
|