为什么在Ajax Control Toolkit中使用ValidatorCallOut时我的整个页面会刷新?

时间:2010-01-31 19:47:35

标签: asp.net ajax asp.net-ajax ajaxcontroltoolkit

我下载了Ajax Control Toolkit,并希望将其组件添加到我的项目中。我使用ValidatorCallOut Component作为文本框的扩展程序,当用户将焦点更改为另一个Textbox时,会弹出ValidatorCallOut。但此操作将导致页面刷新。我怎么能防止这种情况?
这是我的代码:

<%@ Page Language="C#" MasterPageFile="~/User/UserMasterPage.master" AutoEventWireup="true"
    CodeFile="New.aspx.cs" Inherits="User_Accounts_New" Title="Untitled Page" %>

<%@ Register
    Assembly="AjaxControlToolkit"
    Namespace="AjaxControlToolkit"
    TagPrefix="act" %>

<asp:Content ID="Content2" ContentPlaceHolderID="LeftContentPlaceHolder" runat="Server">
    <act:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />

            <asp:TextBox ID="LoginUrlTxtb" CssClass="textEntry" TabIndex="0" runat="server" Width="321px"
                OnTextChanged="LoginUrlTxtb_TextChanged" AutoPostBack="True"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                ErrorMessage="Url is Not Well Formated" ControlToValidate="LoginUrlTxtb">*</asp:RegularExpressionValidator>
            <act:ValidatorCalloutExtender ID="RegularExpressionValidator1_ValidatorCalloutExtender"
                runat="server" HighlightCssClass="validatorCalloutHighlight" 
                Enabled="True" TargetControlID="RegularExpressionValidator1" 
                CssClass="validatorCalloutHighlight" PopupPosition="Left" Width="200px">
            </act:ValidatorCalloutExtender>

            <asp:TextBox ID="FirstnameTxtb" CssClass="textEntry" TabIndex="0" runat="server" Width="321px"
                OnTextChanged="LoginUrlTxtb_TextChanged" AutoPostBack="True"></asp:TextBox>
</asp:Content>

1 个答案:

答案 0 :(得分:0)

您的文本框的"AutoPostBack"属性设置为true。因此,每当他们失去焦点时,他们都会向服务器发送回发,页面将刷新。