Search code examples
sharepointuser-controlsweb-partssmartpart

Sharepoint-customizing usercontrol property in smartpart


If anyone is having idea how to customize properties in a smartpart. I have created usercontrol and i m wrappin it in a smartpart.I want to upload my xml from Document library.

private string feedXML;
        [Browsable(true),
        Personalizable(true) ]


        public string FeedXML
        {
            get
            { return feedXML; }

            set
            { feedXML = value; }
        }

and I am using this like //

feedXML="\customxml.xml";
    XPathDocument doc = new XPathDocument(Server.MapPath(feedXML));

but this thing is not working . When I am clicking on modify shared webpart of sharepoint page is not rendering. Any clue where I m getting wrong.


Solution

  • You might want to verify the result of your server.mappath statement. It will be something like C:\Inetpub... So your code is trying to retrieve a file from the filesystem that really lives in SharePoint because you have uploaded it to a Document Library.

    If you want that file you'll have to retrieve it using the SharePoint object model, have a look at the GetFileAsString method.

    I agree with Denni..

    Seems like Smartpart is only making it more difficult? What advantages does it have?

    I make my own webpart containers for ascx controls.. very little work and all the control you need. No problems with trust settings either.