tags:

views:

39

answers:

1

Hi,

I am 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)

A: 

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.

Marek Grzenkowicz
yah thats the thng even if I check it like If(feedXML!=null) then proceed but the point is in that case want to show user message to open tool part....Any idea on that?
AB
I can also define some default value to it but I want the user to show msg to select xml from toolpart
AB