前台代码
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PictureBrowseControl.ascx.cs" Inherits="FileUploadUtility.PictureBrowseControl" %>
<input type="hidden" id="FolderPath" runat="server" />
<input type="hidden" id="PictureWidth" runat="server" value="500" />
<table id="PictureBrowseTable" runat="server" width="500">
    <tr>
        <td id="First" runat="server" align="left" width="15%">First&nbsp;</td>
        <td id="Prev" runat="server" align="left">&lt; Previous</td>
        <td id="Next" runat="server" align="right">Next &gt;</td>
    </tr>
    <tr>
        <td colspan="3" align="center" valign="top" ><a id="PictureLink" runat="server" href="" title="Click to show picture in full size" target="_blank"><img id="Picture" runat="server" hspace="5" vspace="5" src="" border="0" width="500" /></a></td>
    </tr> 
    <tr>
        <td id="FileDescription" runat="server" align="left" valign="top" colspan="3"></td>
    </tr>
</table>后台稍微有点长就先不贴了。但在后台里面找不到First、Prev和Next。其他都正常。。我真不知道问题出在哪了

解决方案 »

  1.   

     <td id="First" runat="server" align="left" width="15%">First&nbsp;</td>
      <td id="Prev" runat="server" align="left">&lt; Previous</td>
      <td id="Next" runat="server" align="right">Next &gt;</td>
    红色部分为什么要要,table不是添加了runat="server",
    很久没整BS呢?我学习一下
      

  2.   

    <td id="First" runat="server" align="left" width="15%">First&nbsp;</td>
      <td id="Prev" runat="server" align="left">&lt; Previous</td>
      <td id="Next" runat="server" align="right">Next &gt;</td>
    ???你去看看引用这个Control 的 在页面头部注册了没有
      

  3.   

    后台的也贴上来吧。。using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;
    namespace FileUploadUtility
    {
        public partial class PictureBrowseControl : System.Web.UI.UserControl
        {
            private bool m_bPictureDisplayed = false;        private void ClosePage()
            {
                Response.Clear();
                Response.Write("<script type=\"text/javascript\" language=\"Javascript\">window.close();</script>");
                Response.End();
            }        public void SetFolderPath(string sFolderPath)
            {
                // if (FolderPath.Value != null && FolderPath.Value != "") return;
                if (sFolderPath == null || sFolderPath == "") sFolderPath = Server.MapPath("UploadedFiles").ToLower();
                else
                {
                    sFolderPath = sFolderPath.Trim().ToLower();
                    if (sFolderPath.IndexOf(":") < 0) sFolderPath = Server.MapPath(sFolderPath).ToLower();
                }
                if (Directory.Exists(sFolderPath) == false) Directory.CreateDirectory(sFolderPath);
                if (sFolderPath.StartsWith(Server.MapPath(".").ToLower()) == false) throw new Exception("Folder is not under the website root: " + sFolderPath);
                string sFolderPathCode = (Session["FolderPathCode" + sFolderPath] == null) ? Guid.NewGuid().ToString().Replace("-", "") : Session["FolderPathCode" + sFolderPath].ToString();
                FolderPath.Value = sFolderPathCode;
                Session[FolderPath.Value] = sFolderPath;
                Session["FolderPathCode" + sFolderPath] = sFolderPathCode;
            }        public void SetClass(string sLinkClass, string sFileDescriptionClass, string sTableClass)
            {
                if (sLinkClass != null && sLinkClass != "")
                {
                    Prev.Attributes["class"] = sLinkClass;
                    Next.Attributes["class"] = sLinkClass;
                }
                if (sFileDescriptionClass != null && sFileDescriptionClass != "") FileDescription.Attributes["class"] = sFileDescriptionClass;
                if (sTableClass != null && sTableClass != "") PictureBrowseTable.Attributes["class"] = sTableClass;
            }        public void SetSize(int nPictureWidth)
            {
                if (nPictureWidth >= 100)
                {
                    PictureBrowseTable.Attributes["width"] = nPictureWidth.ToString();
                    PictureWidth.Value = nPictureWidth.ToString();
                }
            }        public void DisplayPicture()
            {
                if (m_bPictureDisplayed) return;
                try
                {
                    if (FolderPath.Value == null || FolderPath.Value == "") SetFolderPath(null);
                    string sFolderPath = Session[FolderPath.Value].ToString();
                    string sRoot = Server.MapPath(".").ToLower() + "\\";
                    string sRelativePath = sFolderPath.Substring(sRoot.Length);
                    string sAbsUri = Request.Url.AbsoluteUri.ToLower();
                    int nExt = sAbsUri.IndexOf(".aspx");
                    if (nExt < 0) throw new Exception("Invalid URI: " + sAbsUri);
                    int nPageStart = sAbsUri.Substring(0, nExt).LastIndexOf("/");
                    if (nPageStart < 0) nPageStart = sAbsUri.Substring(0, nExt).LastIndexOf("\\");
                    if (nPageStart < 0) throw new Exception("Invalid URI: " + sAbsUri);
                    string sBrowsePage = sAbsUri.Substring(nPageStart + 1, nExt - nPageStart - 1) + ".aspx";
                    string sBrowsePagePath = Server.MapPath(sBrowsePage);
                    int nIndex = (Request.QueryString["Index"] == null) ? 0 : Convert.ToInt32(Request.QueryString["Index"]);
                    if (nIndex == 0) Session.Remove("UploadFileInfo");
                    bool bMostRecentFirst = (Request.QueryString["MostRecentFirst"] == null) ? false : Convert.ToBoolean(Request.QueryString["MostRecentFirst"]);
                    UploadFileInfo[] pUploadFileInfo = (UploadFileInfo[])Session["UploadFileInfo"];
                    if (pUploadFileInfo == null)
                    {
                        pUploadFileInfo = Tools.GetUploadFileInfo(sFolderPath);
                        Session["UploadFileInfo"] = pUploadFileInfo;
                    }
                    if (pUploadFileInfo.Length == 0) ClosePage();
                    nIndex = nIndex % pUploadFileInfo.Length;
                    int nPrev = nIndex > 0 ? (nIndex - 1) : (pUploadFileInfo.Length - 1);
                    bool bIsSlideShow = IsSlideShow();
                    if (bIsSlideShow)
                    {
                        First.InnerHtml = "";
                        Prev.InnerHtml = "";
                    }
                    else
                    {
                        string sFirstHTML = First.InnerHtml;
                        sFirstHTML = "<a href=\"" + sBrowsePage + "?Index=0&MostRecentFirst=" + (bMostRecentFirst ? "true" : "false") + "\">" + sFirstHTML + "</a>";
                        First.InnerHtml = sFirstHTML;
                        string sPrevHTML = Prev.InnerHtml;
                        sPrevHTML = "<a href=\"" + sBrowsePage + "?Index=" + nPrev.ToString() + "&MostRecentFirst=" + (bMostRecentFirst ? "true" : "false") + "\">" + sPrevHTML + "</a>";
                        Prev.InnerHtml = sPrevHTML;
                    }
                    int nIndex2 = (bMostRecentFirst == false) ? nIndex : (pUploadFileInfo.Length - nIndex - 1);
                    UploadFileInfo oFileInfo = pUploadFileInfo[nIndex2];
                    string sDescHTML = HttpUtility.HtmlEncode(oFileInfo.m_sDescription);
                    FileDescription.InnerHtml = sDescHTML;
                    string sImageURL = sRelativePath + "/" + oFileInfo.m_sFileName;
                    if (Tools.IsFilePicture(oFileInfo.m_sFileName) == false)
                    {
                        string sExt = oFileInfo.m_sFileName.Substring(oFileInfo.m_sFileName.LastIndexOf("."));
                        sImageURL = sRelativePath + "/t_" + oFileInfo.m_sFileName.Replace(sExt, ".jpg");
                    }
                    Picture.Src = sImageURL;
                    PictureLink.HRef = sImageURL;
                    Picture.Width = Convert.ToInt32(PictureWidth.Value);
                    int nNext = (nIndex + 1) % pUploadFileInfo.Length;
                    string sNextHTML = Next.InnerHtml;
                    sNextHTML = "<a href=\"" + sBrowsePage + "?Index=" + nNext.ToString() + "&MostRecentFirst=" + (bMostRecentFirst ? "true" : "false") + "\">" + sNextHTML + "</a>";
                    Next.InnerHtml = sNextHTML;
                    if (bIsSlideShow)
                    {
                        if (Session["NextPage" + FolderPath.Value] == null) Session["NextPage" + FolderPath.Value] = nIndex;
                        else
                        {
                            Session.Remove("NextPage" + FolderPath.Value);
                            if ((nIndex + 1) == pUploadFileInfo.Length)
                            {
                                EndSlideShow();
                                ClosePage();
                            }
                            Response.Redirect(sBrowsePage + "?Index=" + nNext.ToString() + "&MostRecentFirst=" + bMostRecentFirst.ToString());
                        }
                    }
                }
                catch (Exception) { throw; }
                finally { m_bPictureDisplayed = true; }
            }        public void OpenSlideShow()
            {
                if (FolderPath.Value != null && FolderPath.Value != "")
                {
                    Session["SlideShow" + FolderPath.Value] = true;
                }
            }        public void EndSlideShow()
            {
                if (FolderPath.Value != null && FolderPath.Value != "")
                {
                    Session.Remove("SlideShow" + FolderPath.Value);
                }
            }        public bool IsSlideShow()
            {
                return (FolderPath.Value == null || FolderPath.Value == "") ? false : (Session["SlideShow" + FolderPath.Value] != null);
            }        protected void Page_Load(object sender, EventArgs e)
            {
                try
                {
                    if (m_bPictureDisplayed == false) DisplayPicture();
                }
                catch (Exception) { throw; }
                finally { m_bPictureDisplayed = false; }
            }
        }
    }
      

  4.   

    复制的话,控件没有在.cs.design里面注册,所以报错,
    把之前页面的cs.design也复制过来
      

  5.   

    没有这个文件啊。。何况。就那三个有问题。但FileDescription什么的就没问题。
      

  6.   

    疯了。。在后台FileDescription就可以显示出HtmlTableCell PictureBrowseControl.FileDescription
    那三个就不行
      

  7.   

    我拷贝你的代码测试在VS2010里面是没问题的。你可以先把文件备份,删除新建一次试试
    或者把你完整的ascx,cs文件发来看看