自定义图像旋转器Web部件中的错误 [英] Error in custom image rotator web part

查看:77
本文介绍了自定义图像旋转器Web部件中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在自定义图像旋转器Web部件中遇到问题.
以下是我在Web部件中使用的代码.我成功部署了Web部件,但是当我将Web部件添加到我的网站页面中时,出现错误.
谁能告诉我为什么添加Web部件时出现错误.

Hi,
I am facing problem in custom image rotator web part.
below is the code that i use in the web part.i successfully deploy the web part but when i add the web part in the page of my site i am getting error.
Can anyone tell me why i am getting error while adding the web part.

using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace ImageRotatorWebPart
{
    [Guid("c154fc8b-eb18-4db3-890f-2f6e82908f29")]
    public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart
    {
        public WebPart1()
        {
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            AdRotator ad = new AdRotator();
            ad.AdvertisementFile = "~/XMLFile1.xml";
            Controls.Add(ad);

            // TODO: add custom rendering code here.
            // Label label = new Label();
            // label.Text = "Hello World";
            // this.Controls.Add(label);
        }
        protected override void Render(HtmlTextWriter writer)
        {
            //base.Render(writer);

        }
        public override void RenderControl(HtmlTextWriter writer)
        {
            //base.RenderControl(writer);
            RenderChildren(writer);
        }

    }
}

推荐答案

在不知道错误是什么的情况下,我猜这是因为这一行

Without knowing what the error is I would guess it is because of this line

ad.AdvertisementFile = "~/XMLFile1.xml";



SharePoint不像ASP.NET应用程序.您无需将文件放在IIS应用程序路径中,它们是通过库或列表来自内容数据库的,还是来自布局文件夹的文件.

我怀疑您需要先尝试了解SharePoint上的一些文档,然后再尝试为其创建Webparts.



SharePoint is not like an ASP.NET application. You don''t place files in the IIS application path, they come from the content database via libraries or lists or from the layouts folder.

I suspect you need to read through some documentation on SharePoint before trying to create webparts for it.


这篇关于自定义图像旋转器Web部件中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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