?
Solved

I Can't use a FileUpload control in a UpdatePanel (Ajax) ?

Posted on 2007-04-05
15
Medium Priority
?
1,016 Views
Last Modified: 2013-11-26
I Can't use a FileUpload control in a UpdatePanel (Ajax) ?

This structure don’t have problems.

>          [ MasterPage [ ContentPlaceHolder [ UserControl [ FileUpload ] ] ] ]

But I have this structure:

>          [ MasterPage [ ContentPlaceHolder [ UpdatePanel [ UserControl [ FileUpload ] ] ] ]


With this code I have the error: Object reference not set to an instance of an object
>          Dim uploadImage As System.Drawing.Image
>          Dim Temp As New FileUpload
>          Temp = FileUpload1
>          uploadImage = System.Drawing.Image.FromStream(Temp.PostedFile.InputStream)

I try
FindeControl(“FileUpLoad1”)
UpdatePanel.FindeControl(“FileUpLoad1”)
UserControl.FindeControl(“FileUpLoad1”)
FindControl(“UpdatePanel”).FindeControl(“FileUpLoad1”)
FindControl(“UserControl”).FindeControl(“FileUpLoad1”)

ETC !!!...

But nothing…

Note: ASP.NET, VB.NET, VS2005 and Ajax 1.0
0
Comment
Question by:darcosys
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
15 Comments
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18859129
You're likely running into an issue with the naming of nested controls. Try:

FindControl(FileUpload1.ClientId)
0
 
LVL 1

Author Comment

by:darcosys
ID: 18859232
Nop :(

The same error !!!

>      Dim uploadImage As System.Drawing.Image
>      Dim Temp As New FileUpload
>      Temp = FindControl(FileUpload1.ClientID)
>      uploadImage = System.Drawing.Image.FromStream(Temp.PostedFile.InputStream)
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18859263
Might be UniqueId instead of ClientId... I can never remeber which to use. And you may have to replace $ with _ or vice-versa.

The easiest way to deal with this is to run your page, look at the source code, find the control you're interested in and note it's name. Then put a breakpoint on the Temp = line... check to see what FileUpload1.ClientId and FileUpload1.UniqueId are...
0
AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

 
LVL 1

Author Comment

by:darcosys
ID: 18859850
ClientID      "ctl00_ContentPlaceHolder1_ControlUpLoad1_FileUpload1"      String
UniqueID      "ctl00$ContentPlaceHolder1$ControlUpLoad1$FileUpload1"      String

:( ???
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18859878
What's the control name in the web page source? (That is.. run the app, surf to the page, right-click >> view source... this will get you the HTML)
0
 
LVL 1

Author Comment

by:darcosys
ID: 18859917
<input type="file" name="ctl00$ContentPlaceHolder1$ControlUpLoad1$FileUpload1" id="ctl00_ContentPlaceHolder1_ControlUpLoad1_FileUpload1" class="TextBox" style="width:340px;" />
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18859932
So... FindControl(FileUpload1.UniqueID) should get the control.

HOWEVER.... why don't you just refer to it as FileUpload1 on the server side?
Dim uploadImage As System.Drawing.Image = System.Drawing.Image.FromStream(Fileupload1.PostedFile.InputStream)
0
 
LVL 1

Author Comment

by:darcosys
ID: 18859982
UniqueID and ClientID Don't work

HOWEVER.... why don't you just refer to it as FileUpload1 on the server side? ...   It was my first attempt
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18860021
Are you calling FindControl on the page or the user control? You need to ask the parent container for the control IIRC.

What about UserControl.FileUpload1 on the server side?
0
 
LVL 1

Author Comment

by:darcosys
ID: 18860061
The problem is this...
The UsuerContro it's on the server but Ajax make noise.
If I Put the UserControl on a free Ajax page works perfect.
0
 
LVL 1

Author Comment

by:darcosys
ID: 18860113
I call the FindControl from de UserControl on the server-side
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18860251
I'm out of suggestions then...
0
 
LVL 1

Author Comment

by:darcosys
ID: 18860260
On the webpage, The same UserControl out of the UpdatePanel works but in the UpdatePanel don't works.
0
 
LVL 6

Accepted Solution

by:
carmodyk earned 2000 total points
ID: 18947565
Read this article, see if this helps:
http://www.codeproject.com/useritems/simpleajaxupload.asp
0
 
LVL 1

Author Comment

by:darcosys
ID: 18948623
Tk
0

Featured Post

Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question