gpt4 book ai didi

c# - AjaxControlToolkit.MaskedEditExtender 错误

转载 作者:太空宇宙 更新时间:2023-11-03 14:11:13 24 4
gpt4 key购买 nike

我已经安装并设置了 AjaxControlToolkit 的 Asp.net 版本。

版本4.1.5

.Net 4.0

对比 2010

我正在尝试使用 AjaxControlToolkit.MaskedEditExtender Ajax 控件。我已经设置了一个 DetailView 和一些允许我访问文本框的自定义模板。

但不断收到此错误:

>     Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
> information about the error and where it originated in the code.
>
> Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
>
> Source Error:
>
> An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location
> of the exception can be identified using the exception stack trace
> below.
>
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an object.]
> AjaxControlToolkit.MaskedEditExtender.OnLoad(EventArgs e) in
> C:\Users\Stephen\Documents\Repos\Superexpert\AjaxControlToolkit\Server\AjaxControlToolkit\MaskedEdit\MaskedEditExtender.cs:95
> System.Web.UI.Control.LoadRecursive() +74
> System.Web.UI.Control.LoadRecursive() +146
> System.Web.UI.Control.LoadRecursive() +146
> System.Web.UI.Control.LoadRecursive() +146
> System.Web.UI.Control.LoadRecursive() +146
> System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> +2207

这是该部分的代码(HTML 页面 .ASPX)

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="New.aspx.cs" Inherits="AequorPubTracker.Account.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

&nbsp;Search:
<asp:TextBox ID="SearchTextBox" runat="server"></asp:TextBox>
&nbsp;
<asp:Button ID="Button1" runat="server" Text="Search" />
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"
AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="LinqDataSource1"
Height="50px" onpageindexchanging="DetailsView1_PageIndexChanging"
style="margin-top: 20px" Width="472px">
<Fields>
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False"
ReadOnly="True" SortExpression="Id" />
<asp:TemplateField>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# BIND("PubId") %>'></asp:TextBox>

</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# BIND("PubID") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("PubId") %>'></asp:Label>
<br />
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Sent_from_naylor") %>'></asp:Label>
<br />
<asp:Label ID="Label4" runat="server" Text='<%# Eval("RecByAequorMgt") %>'></asp:Label>
<br />
<asp:Label ID="Label5" runat="server" Text='<%# Eval("AssignedToAequorRes") %>'></asp:Label>
<br />
<asp:Label ID="Label6" runat="server" Text='<%# Eval("SentTonaylor") %>'></asp:Label>
<br />
<asp:Label ID="Label7" runat="server" Text='<%# Eval("Status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>

<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
TargetControlID="TextBox1"
Mask="999,9999"
MessageValidatorTip="true"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Number"
InputDirection="RightToLeft"
AcceptNegative="Left"
DisplayMoney="Left"
ErrorTooltipEnabled="True"/>


<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender2" runat="server"
TargetControlID="TextBox2"
Mask="999,9999"
MessageValidatorTip="true"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Number"
InputDirection="RightToLeft"
AcceptNegative="Left"
DisplayMoney="Left"
ErrorTooltipEnabled="True"/>

<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="AequorPubTracker.AequorDataDataContext" EnableDelete="True"
EnableInsert="True" EnableUpdate="True" EntityTypeName=""
TableName="Aequor_Pub_Trackers">
</asp:LinqDataSource>

<asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="LinqDataSource1">

<asp:SearchExpression SearchType="StartsWith" DataFields="PubId">
<asp:ControlParameter ControlID="SearchTextBox" />
</asp:SearchExpression>

</asp:QueryExtender>
&nbsp;

</asp:Content>

最佳答案

您收到此错误是因为目标控件嵌套在数据绑定(bind)控件中,而扩展程序无法找到目标控件。尝试将 MaskedEditExtender 放在 DetailsView 控件中。

关于c# - AjaxControlToolkit.MaskedEditExtender 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7810930/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com