473,508 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileUpload and update panel



i have coded like this
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>

<asp:Label ID="Label1" runat="server">
<asp:FileUpload ID="fupLogo" runat="server" Visible="False">

<asp:Button ID="Button2" runat="server" Text="Upload"
OnClick="Button2_Click" Visible="False" />

</asp:FileUpload><asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="show Uploader " />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Button2">
</asp:PostBackTrigger>
</Triggers>
</asp:UpdatePanel>
code behind>>>>>>>>>>>>>>>>>>>

protected void Button2_Click(object sender, EventArgs e)
{
if (fupLogo.HasFile)
{
string fileFormat = fupLogo.PostedFile.ContentType;
Label1.Text = fupLogo.PostedFile.ContentType;
if (string.Compare(fileFormat, "image/jpeg", true) == 0 ||
string.Compare(fileFormat, "image/png", true) == 0 ||
string.Compare(fileFormat, "image/gif", true) == 0)
{
Label1.Text += "file format supported<br/>";
}
else
{
Label1.Text +="file format not supported<br/>";
}
}
else
{
Label1.Text += "file not exist<br/>";
}
}

protected void Button1_Click(object sender, EventArgs e)
{
fupLogo.Visible = true;
Button2.Visible=true;
}

this behaves like on page load it shows a button then the onclick of the
button it shows a fileupload and upload button
Expected: when i cliks upload button after selecting any file
ouput must be "file format supported/not suported"

actual: but the output is "file not exist".
Jul 17 '07 #1
4 7966
On 17 , 10:13, Mukesh <efex...@newsgroups.nospamwrote:
i have coded like this

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>

<asp:Label ID="Label1" runat="server">
<asp:FileUpload ID="fupLogo" runat="server" Visible="False">

<asp:Button ID="Button2" runat="server" Text="Upload"
OnClick="Button2_Click" Visible="False" />

</asp:FileUpload><asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="show Uploader " />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Button2">
</asp:PostBackTrigger>
</Triggers>
</asp:UpdatePanel>

code behind>>>>>>>>>>>>>>>>>>>

protected void Button2_Click(object sender, EventArgs e)
{
if (fupLogo.HasFile)
{
string fileFormat = fupLogo.PostedFile.ContentType;
Label1.Text = fupLogo.PostedFile.ContentType;
if (string.Compare(fileFormat, "image/jpeg", true) == 0 ||
string.Compare(fileFormat, "image/png", true) == 0 ||
string.Compare(fileFormat, "image/gif", true) == 0)
{
Label1.Text += "file format supported<br/>";
}
else
{
Label1.Text +="file format not supported<br/>";
}
}
else
{
Label1.Text += "file not exist<br/>";
}

}

protected void Button1_Click(object sender, EventArgs e)
{
fupLogo.Visible = true;
Button2.Visible=true;
}

this behaves like on page load it shows a button then the onclick of the
button it shows a fileupload and upload button

Expected: when i cliks upload button after selecting any file
ouput must be "file format supported/not suported"

actual: but the output is "file not exist".
Use style="display:none" instead of Visible="False". In this case
PostBackTrigger for Button2 works correctly.
Example:
..aspx file
<asp:FileUpload ID="fupLogo" runat="server" style="display:none"></
asp:FileUpload>
<asp:Button ID="Button2" runat="server" Text="Upload"
OnClick="Button2_Click" style="display:none" />

..cs file
protected void Button1_Click(object sender, EventArgs e)
{
fupLogo.Style.Remove("display");
Button2.Style.Remove("display");
}
Regards,
Mykola

Jul 17 '07 #2
On Jul 17, 10:13 am, Mukesh <efex...@newsgroups.nospamwrote:
<asp:FileUpload ID="fupLogo" runat="server" Visible="False">

<asp:Button ID="Button2" runat="server" Text="Upload"
OnClick="Button2_Click" Visible="False" />
Use style="display:none" instead of Visible="False". In this case
PostBackTrigger for Button2 works correctly.
Example:
..aspx file
<asp:FileUpload ID="fupLogo" runat="server" style="display:none"></
asp:FileUpload>
<asp:Button ID="Button2" runat="server" Text="Upload"
OnClick="Button2_Click" style="display:none" />

..cs file
protected void Button1_Click(object sender, EventArgs e)
{
fupLogo.Style.Remove("display");
Button2.Style.Remove("display");
}
Regards,
Mykola

Jul 17 '07 #3
Hi Mukesh,

I was replying too quick and didn't noticed the Button2 is causing a normal
postback instead of an async postback, therefore my previous reply doesn't
apply for your question. Sorry about that.

Thanks Mykola for the correct fix, I've tested this and it's working
correctly. Please test this on your side and let us know the result.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 18 '07 #4
Walter Wang [MSFT] wrote:
Hi Mukesh,

I was replying too quick and didn't noticed the Button2 is causing a normal
postback instead of an async postback, therefore my previous reply doesn't
apply for your question. Sorry about that.

Thanks Mykola for the correct fix, I've tested this and it's working
correctly. Please test this on your side and let us know the result.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dear
Walter and mykola
Thanks for the reply

Jul 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5337
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In...
2
11378
by: ronc85 | last post by:
My environment is ASP.NET 2.0, C# and AJAX. Is there a way to retain the Postedfile in the FileUpload control after Postback? I have this application I've inherited were the User chooses a file...
1
1652
by: fran_j_diaz | last post by:
Hi, I've got a problem with a FileUpload in a updatePanel. My update Panel is triggered with a button. I select a file in my file upload and when I do a postback with my button, the...
1
1463
by: Code Monkey | last post by:
I've got a FileUpload control placed on a web page. The control is embedded inside an UpdatePanel. It uploads the file OK, but.... Load the page, click on a button to show the upload panel....
1
1380
by: Microsoft Newsserver | last post by:
HI Im developing a solution in vs2005 with ajex extensions. Essentially I have three custom controls which render tables a representation as shown below. The problem is that when any of...
9
9716
by: vital | last post by:
Hi, I have a User control which has a fileupload control. With the requirements I placed the user control in a UpdatePanel of ASP.NET Ajax and the fileupload.postedfile.filename giving error. ...
0
1652
by: nityaprashant | last post by:
hello.. i used ajax update panel in my cart form now i want to use paypal button for redirect online transaction because of ajax update panel round trip is not possible.. so paypal button gives...
6
2079
by: GaryDean | last post by:
Is there any way to make an asp FileUpload control work within an UpdatePanel? Thanks, Garyh
3
2635
by: Fresno Bob | last post by:
I know this has been addressed sortof. It's using the update panel with the fileupload control. I get how to use a postback trigger to do a full postbask. However my page has some server side...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.