开发者

personalize webpart-problem in giving url to xml file in toolpart

I a开发者_高级运维m creatng a webpart and I am tryng to reference xml from toolpart . I hv created custom properties and its fine if I set the default value to some url otherwise its showing msg fle not found. I want that if its the first time I am loading file it should display the message Open tool part to select the XML.

I m doing lke ths:

private string feedXML;
        [Browsable(true),
        Personalizable(true),
         Category("Example Web Parts"),
         DefaultValue(""),
         WebPartStorage(Storage.Shared),
         FriendlyName("MySetting"),
         Description("An example setting")]

        public string FeedXML
        {
            get
            { return feedXML; }

            set
            { feedXML = value; }
        }
string xmlurl = String.Empty;
                string _xsl = string.Empty;
                // Load the XML

                xmlurl = web.GetFileAsString(GetRelativeURL(feedXML));<---exception as feedXML is null

                XmlDocument doc = new XmlDocument();

                doc.LoadXml(xmlurl);

As the frst time webpart is loadng its quite obvious it wud be feedXML wud be null but I want to display the msg to user "Select XML frm toolpart" as we generally get when we add OOB webpart (like XML Webpart)


Override the CreateChildControls method; if feedXML is null, create a label that says Open tool pane ... and add it to Web Part's Control collection.

Also, check the Creating a Web Part with a Custom Tool Part article.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜