Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationI am unable to use file upload control in user account module of dnn 481I am unable to use file upload control in user account module of dnn 481
Previous
 
Next
New Post
5/12/2008 6:38 AM
 

I used file upload control for uploading photo but its throwing error "object reference not set to an instance of an object" only in dnn 481,dnn 482 versions. I used same control in dnn 470 version there it works fine.

 
New Post
5/12/2008 11:21 AM
 

Without seeing the code you're using it's difficult to know where the problem is.

 
New Post
5/13/2008 12:30 AM
 

Hello Sir,

Please see the code below

I used btn as  asp button control,fu as asp file upload control,img as asp image control

I am getting error in  this line  " contLength = fu.PostedFile.ContentLength" as object refererence not set to an instance of an object.
I am able to get file upload control's ID but I am not able to  capturethe content of that upload control.

Pls give me a soln.

Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click
            Dim contLength As Integer
            contLength = fu.PostedFile.ContentLength
            Dim myData(contLength) As Byte
            fu.PostedFile.InputStream.Read(myData, 0, contLength)
            Dim strpath As String = "C:\Inetpub\wwwroot\iredver1.0\CompanyLogo"
            Dim strfileName As String = Path.GetFileName(fu.PostedFile.FileName)
            Dim strpth As String = ""
            strpth = Path.Combine(strpath, strfileName)
            fu.SaveAs(strpth)
            img.ImageUrl = strpth

  End Sub

 

 
New Post
5/13/2008 5:52 PM
 

It looks to me like the value for fu isnot being kept. Is this a global variable? This isn't so much a problem with any of the authentication codes but rather with something core related or with your code itself.

 
New Post
5/13/2008 9:40 PM
Accepted Answer 

If your module is wrapped in an AJAX UpdatePanel or has "Supports Partial Rendering" checked in the module's control definition, the FileUpload control will not be able to perform the upload as it requires a full postback. Without a full postback, the property fu.PostedFile would always be null.

If you want to use an AJAX UpdatePanel or "Supports Partial Rendering",  the button control which triggers the upload will need to be registered as a PostBackControl in the module control's Page_Init or Page_Load handler. As the following code will need to be called each time the page loads, do NOT place it within a If Not Page.IsPostback condition:

If DotNetNuke.Framework.AJAX.IsEnabled Then
      DotNetNuke.Framework.AJAX.RegisterPostBackControl(btn)
End If

As an aside, you might also like to check out my ImageEditorControl for DNN at www.codeplex/imageeditor as it provides file upload, image preview, and basic image editing including cropping and enhancement, auto-resizing and thumbnailing, and save to any of the DNN file storage systems.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationI am unable to use file upload control in user account module of dnn 481I am unable to use file upload control in user account module of dnn 481


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out