如何在另一个 ASPX 文件上创建服务器控件

发布于 2024-08-29 05:14:11 字数 710 浏览 3 评论 0原文

我正在 VS 2008 中开发一个 C#/SQL ASP.NET Web 应用程序。目前,我正在将控制从一个 ASPX 文件转移到另一个:

    if (uploadFile.PostedFile.ContentLength > 0)
    {
        inputfile = System.IO.File.ReadAllText(path);
        Context.Items["Message"] = inputfile; //Page1
        Server.Transfer("DataMatch.aspx"); //Page1
    }

后,它在此 Server.Transfer 行上失败

runat="server"

但是,在将DataMatch.aspx 文件插入到表 像这样的元素:

<table width="50%" id="tMain" runat="server">

但是在将其设为服务器控件后,我重建了它,现在当我运行此应用程序时,它给了我异常:

Error executing child request for DataMatch.aspx

但我需要此表作为服务器控件,以便在发生某种情况时可以通过编程方式使其不可见。我还能如何以编程方式使该表不可见?

I am developing a C#/SQL ASP.NET web application in VS 2008. Currently, I am transferring control from one ASPX file to another:

    if (uploadFile.PostedFile.ContentLength > 0)
    {
        inputfile = System.IO.File.ReadAllText(path);
        Context.Items["Message"] = inputfile; //Page1
        Server.Transfer("DataMatch.aspx"); //Page1
    }

However, it fails on this Server.Transfer line after inserting

runat="server"

in the DataMatch.aspx file to the Table element like so:

<table width="50%" id="tMain" runat="server">

But after making this a server control, I rebuilt it and now when I run this app it gives me exception:

Error executing child request for DataMatch.aspx

But I need this table to be a server control so I can make it invisible programmatically if a certain condition occurs. How else can I programmatically make this table invisible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浴红衣 2024-09-05 05:14:11

从表中删除“runat”标记,并将其包装在 标记中。将可见性属性应用到面板。

remove the "runat" tag from the table, and instead wrap it in an <asp:Panel> tag. Apply the visibility attribute to the panel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文