Label existiert nicht im aktuellen Kontext asp.net Seite und ajax control

bevor ich beginne, gibt es eine weitere Frage, die mit einem ähnlichen Titel und es ist ungelöst, aber meine situation ist ziemlich anders, da bin ich mit Ajax.

Vor kurzem habe ich ein label für meine Ajax-UpdateProgress-Steuerelement und für einige Grund meine asp.net Seite ist nicht zu Lesen. Mein ursprüngliche Ziel war es, die für den text des Labels zu sein, die ständig aktualisiert werden, während die lang-Methode ausgeführt wird. Ich bin mit code hinter, und ich glaube, das Etikett deklariert ist. Ich poste meine .cs-Seite, wenn jemand Lust hätte zu Lesen, durch es (nicht zu lange), Alle meine anderen labels perfekt funktionieren und selbst wenn ich die Beschriftung AUS dem ajax control wird es funktionieren (nicht den text aktualisiert, wenn). Gibt es eine bestimmte Ajax-label muss ich verwenden?

Im ziemlich verwirrt, warum der Fehler Auftritt. Die genaue Fehlermeldung lautet : "Der name 'lblProgress' existiert nicht im aktuellen Kontext. Im mit c#, ajax-Steuerelemente, eine asp.net Seite, und visual studio. Dieses Programm lädt eine Datei hoch, um einem client und speichert die Informationen in einer Datenbank. Wenn jemand helfen kann, würde ich es wirklich schätzen. Vielen Dank im Voraus!

    using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Threading;


public partial class SendOrders : System.Web.UI.Page
{
protected enum EDIType
{
    Notes,
    Details
}

protected static string NextBatchNum = "1";
protected static string FileNamePrefix = "";
protected static string OverBatchLimitStr = "Batch file limit has been reached.  No more batches can be processed today.";

protected void Page_Load(object sender, EventArgs e)
{
    Initialize();
}
protected void Page_PreRender(object sender, EventArgs e)
{
}
protected void Button_Click(object sender, EventArgs e)
{
    PutFTPButton.Enabled = false;
    lblProgress.Visible = true;
    lblProgress.Text = "Preparing System Checks...";
    Thread.Sleep(3000);
    Button btn = (Button)sender;
    KaplanFTP.BatchFiles bf = new KaplanFTP.BatchFiles();
    KaplanFTP.Transmit transmit = new KaplanFTP.Transmit();

    if (btn.ID == PutFTPButton.ID)
    {
        lblProgress.Text = "Locating Files...";
        //bf.ReadyFilesForTransmission();
        DirectoryInfo dir = new DirectoryInfo(@"C:\Kaplan");
        FileInfo[] BatchFiles = bf.GetBatchFiles(dir);
        bool result = transmit.UploadBatchFilesToFTP(BatchFiles);
        lblProgress.Text = "Sending Files to Kaplan...";
        if (!result)
        {
            ErrorLabel.Text += KaplanFTP.errorMsg;
            return;
        }
        bf.InsertBatchDataIntoDatabase("CTL");
        bf.InsertBatchDataIntoDatabase("HDR");
        bf.InsertBatchDataIntoDatabase("DET");
        bf.InsertBatchDataIntoDatabase("NTS");
        List<FileInfo> allfiles = BatchFiles.ToList<FileInfo>();
        allfiles.AddRange(dir.GetFiles("*.txt"));
        bf.MoveFiles(allfiles);
        lblProgress.Text = "Uploading File Info to Database...";
        foreach (string order in bf.OrdersSent)
        {
            OrdersSentDiv.Controls.Add(new LiteralControl(order + "<br />"));
        }
        OrdersSentDiv.Visible = true;
        OrdersInfoDiv.Visible = false;
        SuccessLabel.Visible = true;
        NoBatchesToProcessLbl.Visible = true;
        BatchesToProcessLbl.Visible = false;
        PutFTPButton.Enabled = false;
        BatchesCreatedLbl.Text = int.Parse(NextBatchNum).ToString();
        Thread.Sleep(20000);

        if (KaplanFTP.errorMsg.Length != 0)
        {
            ErrorLabel.Visible = true;
            SuccessLabel.Visible = false;
            ErrorLabel.Text = KaplanFTP.errorMsg;
        }
    }
}

Hier ist meine aspx-code.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SendOrders.aspx.cs" Inherits="SendOrders" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
   <title>Kaplan EDI Manager</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            width: 220px;
            height: 19px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="mainPanel">
        <div>
            <h3>Number of Batches Created Today: <asp:Label runat="server" style="display:inline;" ID="BatchesCreatedLbl"></asp:Label>
                <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
                <span class="red">COUNTDOWN TO SUBMISSION!</span>
                <span id="timespan" class="red"></span>
            </h3>
        </div>
        <div id="batchestoprocessdiv">
        </div>

        </asp:UpdatePanel>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="BatchesToProcessLbl" runat="server" CssClass="green" 
                    Height="22px" Text="THERE IS AN ORDER BATCH TO PROCESS."></asp:Label>
                <asp:Label ID="NoBatchesToProcessLbl" runat="server" CssClass="red" 
                    Text="There are no Order Batches to Process." Visible="false"></asp:Label>
                <asp:Button ID="PutFTPButton" runat="server" onclick="Button_Click" 
                    Text="Submit Orders" />
                <asp:Label ID="SuccessLabel" runat="server" CssClass="green" 
                    Text="Batch has been processed and uploaded successfully." Visible="false"></asp:Label>
                <asp:Label ID="ErrorLabel" runat="server" CssClass="red" Text="Error: " 
                    Visible="false"></asp:Label>
                <asp:Label ID="lblProgress" runat="server" CssClass="green" Height="16px" 
                    Text="Label" Visible="False"></asp:Label>
                <br />
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" 
            AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <br />
                <img alt="" class="style1" src="images/ajax-loader.gif" />
            </ProgressTemplate>
        </asp:UpdateProgress>
    </div>
    <div id="OrdersInfoDiv" runat="server" visible="false">
        <asp:GridView ID="BatchDetails" Caption="Details of orders ready to be sent" runat="server" AutoGenerateColumns="true" 
        CssClass="InfoTable" AlternatingRowStyle-CssClass="InfoTableAlternateRow" >
        </asp:GridView>
    </div>
    <div id="OrdersSentDiv" class="mainPanel" runat="server" visible="false">
        <h4>Sent Orders</h4>
    </div>
    </form>
    <script src="js/SendOrders.js" type="text/javascript"></script>
</body>
</html>
  • können Sie nach Ihrer aspx-Teil
  • jetzt aktualisiert 🙂 vielen Dank für Ihre Zeit.
InformationsquelleAutor javasocute | 2011-10-31
Schreibe einen Kommentar