Showing posts with label image. Show all posts
Showing posts with label image. Show all posts

Monday, March 26, 2012

prevent asp:ImageButton from refreshing image...

Is there a way (with the Dec release) to prevent the image in an image button from refreshing when posting back to the server in an UpdatePanel?

It would seem to defeat the purpose of Ajax to have this image refresh all the time during a post to the server...

Wade.

The idea would be to keep the image button outside the updatepanel so it is not refreshed when the page is posted back.

- Kashif


Actually the behavior is browser dependent. Internet Explorer seems to refresh images by trying to go to reload the image, while Mozilla seems to cache images completely locally and without that funky flash.

In IE if you replace content that contains images references (as UpdatePanel will do) all the images reload. Usually they will come from Cache so it's pretty fast, but there's still some amount of flash. If you use FireFox you don't get that flash. You can hook up Fiddler or other HTTP proxy to see this behavior.

Certainly makes for smoother operation of any sort of callback in FireFox.

+++ Rick --


The best method is to have a script manager control on the page with 'Enable Partial Rendering' set to 'True', and then only put the parts of your page that would be updated on a page refresh within the UpdatePanel controls.

So if you don't want the image to 'blink', it's best to leave it outside of that control.


This is a problem that is currently driving me nuts. I have a large UpdatePanel that has a tab control on it. The tabs are painted using image backgrounds defined in a stylesheet. In IE, using Nikhil's web dev tool, I can see that for every tab all the images are requested and the server responds with code 200. It's like IE's local cache is completely ignored. This is causing an ugly flicker and some repaint issues. I've tried the max-age cache control-cache extension but it doesn't seem to work. I found the best information athttp://aspnetresources.com/blog/cache_control_extensions.aspx.

Does anyboy have any ideas?

This bug is going to kill me too. all the images on the page even those are outside the updatepanel and wrote with <img> tag are flikering too.

Any solution to resolve this problem?


The image flicker has nothing to do with ATLAS - it's an IE bug - IE is refreshing the images when it shouldn't. You can fix that by changing your IE cache settings. I think it happens if you have your cache set to refresh on every page hit. IE apparently considers the partial XmlHttp postback as a page refresh and refreshes all content in the page. Put IE back to auto caching and the flickering should stop.

+++ Rick --


Dear Rick

Thanks For Comment

My IE Caching was set to Auto Already, and here still the killer bug.

Any other Idea?

H.B.F


Hello. This is a bug in IE when it's pulling in background images defined in CSS. As far as I am aware, the solution lies within IIS. Have a read of this: http://erik.eae.net/archives/2007/02/26/13.13.48/

cheers
Anthony

Saturday, March 24, 2012

Problem In CollapsablePanel Extender

Hi Frnds,

I m new to Ajax, and i m using some toolkit extenders for my application.

When i declared a Label and an Image in the Header Panel of a CollapsablePanelExtender, its displaying controls on separate lines.

but i want to display label on the left side and image on right side.

Is there any tech to do like this since its taking more space and looking bad.

thanks in advance

Regards

Hasan

Hi Hasan,

I think you problem is a CSS related issue. Actually, itemplate header works as a div container but it is not recommended to changes its CSS directly. We suggest that you add another container (div) and add css style to the newly added container. For example,

<div style="width: 100%;">
<asp:Label ID="Label1" runat="server" Text="Label" Style="float: left"></asp:Label>
<asp:Button ID="Button2" runat="server" Text="Button" Style="float: right" /></div>

Another way is using a Table to control its showing position.

Best regards,

Jonathan

Wednesday, March 21, 2012

Problem in file uploading with Ajax

I want to upload an image on server. My source below is working well. But when I keep the same things in Update Panel it didn't work. Can some one help me on this strange behavior please?

Thanks!

ImageUpload.aspx.cs
 
using System;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
 
namespace Articles
{
   publicclass Default : Page
   {
       public HtmlInputFile   Picture;
       public Label           Message;
       public Image           UploadedPic;
 
       publicvoid UploadImage(object sender, EventArgs e)
       {
           if (Picture.PostedFile !=null)
           {
               string PicType = Picture.PostedFile.ContentType.ToString();
               if (PicType == "image/jpeg" || PicType == "image/gif" || PicType == "image/pjpeg"
                   || PicType == "image/bmp")
               {
                   try
                   {
                       string PicName = Picture.PostedFile.FileName;
                       string NewPicName = (string)Session.SessionID + "_" + PicName.Substring(PicName.LastIndexOf(@dotnet.itags.org."\")+1);
                       string UploadPath = Request.PhysicalApplicationPath + @dotnet.itags.org."\Upload\";
 
                       Picture.PostedFile.SaveAs(UploadPath + NewPicName);
 
                       Message.Text = "Picture successfully uploaded to server!";
                       UploadedPic.AlternateText = "Uploaded picture...";
                       UploadedPic.ImageUrl = UploadPath + NewPicName;
                       UploadedPic.Visible =true;
                   }
                   catch (Exception exc)
                   {
                       Message.Text = exc.ToString();
                   }
               }
               else
                   Message.Text = "File format not supported!";
           }
       }
   }
}

ImageUpload.aspx
 
<%@dotnet.itags.org. Page Language="C#" Codebehind="ImageUpload1.aspx.cs" Inherits="Articles.Default" %>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Image Upload #1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
 
<h3>Image Upload #1</h3>
<form enctype="multipart/form-data" runat="server">
   <table>
       <tr>
           <td>Image:</td>
           <td><input id="Picture" type="file" runat="server"/></td>
       </tr>
   </table>
   <br/>
   <input type="submit" value="Upload >>>" onserverclick="UploadImage" runat="server"/>
</form>
 
<asp:label id="Message" runat="server"/>
 
<hr>
 
<asp:image id="UploadedPic" visible="False" runat="server"/>
 
</body>
</html>

Hi,

unfortunately the FileUpload control, like some other controls, don't work together with the UpdatePanel. So no go.

You can check the controls out that don't work with it here:

Taken from the documentation:http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx

Controls that Are Not Compatible with UpdatePanel Controls

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside anUpdatePanel control:

TreeView andMenu controls.