如何创建另一个ASPX文件服务器控件 [英] How to create a server control on another ASPX file

查看:136
本文介绍了如何创建另一个ASPX文件服务器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展在VS 2008目前一个C#/ SQL ASP.NET Web应用程序,我把控制权从一个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
    }

然而,它不能在这行Server.Transfer的后插入

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

runat="server"

在DataMatch.aspx文件到表元素,像这样:

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?

推荐答案

从表中删除了RUNAT的标签,而是在&LT把它包; ASP:面板&gt; 标记。应用能见度属性到面板

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

这篇关于如何创建另一个ASPX文件服务器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆