views:

302

answers:

2

Hi,

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.

A: 

Are you sure this is correct?

feedXML="\customxml.xml";

Perhaps, what you want is:

feedXML="\\customxml.xml"; //escape the back-slash.

or

feedXML="/customxml.xml"; // use the forward-slash.

Anyway, if you just want to wrap your user control inside a Web part, you don't need the SmartPart. You can write your custom Web part yourself quite easily.

denni
Thanks Denni for replying the thing is we r using Smartpart bcoz of its ease of use with usercontrols I know we can do it other way but SmartPart has other advantages....No I tried the way u r saying but its still the same ...Page is not reendering when I m clicking on modify shared webpart of smartpart ....means do u hv any idea how to do it...Do i need to use SmartPart.Iusercontrol for it...and define properties...or I can do the same way in usercontrol the i do in webpart and it will reflect in my smartpart
AB
A: 

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.

ArjanP