Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How to implement openfile dialog in a webpart ?
OpenFileDialog class could not be accessed in webpart.
Is there any other way to achieve this ? File Browse Dialog

share|improve this question
    
what exactly are you trying todo? open a file from a site? or save to a site? –  ali Sharepoint Mar 25 '13 at 12:49
    
@aliSharepoint I want to upload a document to the site. The user should be able to browse the file. –  Laxman Mar 25 '13 at 12:55
add comment

1 Answer

up vote 1 down vote accepted

ahh ok, your looking for fileupload:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx

Displays a text box control and a browse button that enable users to select a file to upload to the server.

http://msdn.microsoft.com/en-us/library/ms454491(v=office.12).aspx

This programming task shows how to upload a file from a local folder to a folder on a Microsoft SharePoint Foundation site. The task uses the EnsureParentFolder method to ensure that the destination folder exists.

EDIT

i understand that your using a webpart instead of aspx page! but what you can do in aspx you can do in .cs , so in your case:

protected override void CreateChildControls()
{
    //create the textbox file object
    HtmlInputFile tbuploadfile = new HtmlInputFile();
    //add the newly created HtmlInputFile to the controls
    //when you run the code add it to the page you should see that new control
    this.Controls.Add(tbuploadfile);
}

so just do the same as above for what its asking for in the aspx but convert it to .cs instead... its simple todo as above :) . wss 3.0 is a pain the *

END EDIT

scroll to the bottom of the page to show you how its done ;)

another option

http://www.codeproject.com/Articles/95954/Sharepoint-WebPart-for-Programmatically-Uploading

share|improve this answer
    
Actually I dont have .aspx file in my project. In the second link it is specified to add HtmlInputFile to the form on .aspx page. I'm developing sharepoint webpart and my webpart inherits from System.Web.UI.WebControls.WebParts.WebPart. –  Laxman Mar 25 '13 at 13:26
    
changed my answer, checkout the update :) –  ali Sharepoint Mar 25 '13 at 14:12
    
hi, thanks for the update. I got it worked. :) –  Laxman Mar 26 '13 at 7:40
    
glad to see you got it working –  ali Sharepoint Mar 26 '13 at 9:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.