Showing posts with label loading. Show all posts
Showing posts with label loading. Show all posts

Wednesday, March 28, 2012

Updateprogress panel does not disappearing

Hello:

I have a web page with updatepanel and updateprogress. In each callback, updateprogress is showed with a panel "loading".

My problem is that, if I call other web page that opens one PDF in other window, updateprogress does not disappear from the screen:

In button click I have:

Response.Redirect(

"getDocument.aspx",false); //This page does not load on same explorer. It is opened in other window

I have tried adding code at bottom of this sentence, like "UpdatePanel1.Update();" or updateprogress1.visible=false, but no way.

Any ideas?

Thanks and regards

How you are loading the response in another explorer using Response.Redirect or are you opening the window from the client side?

refer this tutorial also:

http://ajax.asp.net/docs/tutorials/ProgrammingUpdateProgress.aspx

referDisplaying Update Progress Using Client Script in the above page.This describes how to intercepte page request manager lifecycle.


Hello and thanks by responding:

I am calling a web page called Getdocument.aspx from code behind (on rowcommand of datagrid). Not from client-side.

This web page "GetDocument.aspx", generates a PDF file with Response.binaryWrite and open it in a new browser. But caller page remains or must remain active.

Regards

Monday, March 26, 2012

updating only portion of a User control

Hi,

I Have an application Where I am dyanmically Loading User controls in a Main Page Content area(in an Update Panel)

And Each user control has its own update panel. for Example I have a List box and a text box and the Text box is in an update panel

And when the user select an item in the list box i need to update the text box upadate panel.

But the problem is since all these controls are in a user control and the user control loads in a place holder in an update panel in my main page.

To get the events of the user control child controls i need to load it again while asynchrounous post back

ie When user selects a menu item i am loading my user control into a place holder in an update panel in the main page.

and when the user clicks on the list box in my user control to get the selected index changed event i need to load the user control again

in my cs code. to the place holder . but i am only updating the text box in my user control. and so i placed that in an update panel.

but the problem is since my user control is inside an update panel in my main page the whole user control get refreshed.

I put the update mode of my main page update panel as conditional and when the user double clicks on the list box i load the user control in the palce holder so that i will get the events but i didn't update the main update panel. I did call only update for the update panel for the text box(which is in my user control)

but still my whole user controls get refeshed . Is there any solution for this

Thanks and regards

jereesh

Where the control that make posteback is located , is it inside your main update panel ?

if yes so you have to set "ChildrenAsTriggers" of your main update panel to false.

please let us know about your aspx code


HiI have a Main page where there is an update panel( where a place holder exists )which is made as conditionalAnd I have user controls(ascx) which are dynamically loaded into this update panel-into the place holder-(when user clicks on different menu items in main page. And inside each user Control there is an update panel where all child controls are placedand I may have update panels for individual controls in user controlfor example in one of my user control I have a list box and a text box and when i double click on the list box i need to change the text box value so i kept the text box inside an update Panel. but the problem is when i click on the list box in a user control if i need to get the event(selected indexchnaged) for that user control i need to load it again to the place holder in the cs file(Main.aspx.cs), ie if may user control name is search.ascxi am usong LoadControl method and adding it to the placeholder in my main page(this should happen each time when any postback occurs because of an event for a child control in the user control- then only i will get its events).I kept all update panel's update mode as conditional. and I will call only update for the update panelwhre my text box exists ( ie the update panel inside my user control). I only call Update for my main update panelonly when I need to load another user control ie when the user selects another menu item from the main page. mainupdatepanel -- Upadated only when new user control is to be loade usercontrolupdatepanel - Updated conditionally usercontrolchildcontrolUpdatepanel-- updates conditionallyThanks and Regards

Hi,

You have to set "ChildrenAsTriggers" of your main update panel to false.

Best Regards,

Saturday, March 24, 2012

Upload Progress Bar

So I'm taking a file and loading it into a stream and then displaying that file. I'm wondering if there is a way to add a progress bar that will show how much of the upload has finished. I've googled for something that tells me how to track the completion of the upload into the stream, but couldn't find anything.

Can someone point me in the right direction?

Here's my code:


1FileStream fs =new FileStream(FileUpload1.FileName, FileMode.OpenOrCreate, FileAccess.Read);
2 Byte[] img =new Byte[fs.Length];
34 fs.Read(img, 0, Convert.ToInt32(fs.Length));
56 System.IO.MemoryStream ms =new System.IO.MemoryStream(img);
7//System.IO.Stream ps = new System.IO.MemoryStream(img);
8 //System.Drawing.Bitmap b = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);
9 //System.Drawing.Bitmap b = new System.Drawing.Bitmap(ps);1011 System.Drawing.Bitmap sb = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
1213 sb.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
On the other hand, what I need is an image upload with a preview and upload progress bar, where the preview is cached/dynamically generated and not stored on the disk. 
Thanks!

Hi,rksprst

Need a preview, you can do it like this:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default25 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string oIP = Context.Request.QueryString["oIP"];
MakeThumbnail(oIP, oIP + ".JPG", 100, 0, "W");
}
/// <summary>
///
/// </summary>
/// <param name="originalImagePath"></param>
/// <param name="thumbnailPath"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="mode"></param>
public void MakeThumbnail(string originalImagePath, string thumbnailPath, int width, int height, string mode)
{
System.Drawing.Image originalImage = System.Drawing.Image.FromFile(originalImagePath);

int towidth = width;
int toheight = height;

int x = 0;
int y = 0;
int ow = originalImage.Width;
int oh = originalImage.Height;

switch (mode)
{
case "HW":
break;
case "W":
toheight = originalImage.Height * width / originalImage.Width;
break;
case "H":
towidth = originalImage.Width * height / originalImage.Height;
break;
case "Cut":
if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight)
{
oh = originalImage.Height;
ow = originalImage.Height * towidth / toheight;
y = 0;
x = (originalImage.Width - ow) / 2;
}
else
{
ow = originalImage.Width;
oh = originalImage.Width * height / towidth;
x = 0;
y = (originalImage.Height - oh) / 2;
}
break;
default:
break;
}


System.Drawing.Image bitmap = new System.Drawing.Bitmap(towidth, toheight);


System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);


g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;


g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;


g.Clear(System.Drawing.Color.Transparent);


g.DrawImage(originalImage, new System.Drawing.Rectangle(0, 0, towidth, toheight),
new System.Drawing.Rectangle(x, y, ow, oh),
System.Drawing.GraphicsUnit.Pixel);
try
{
HttpResponse httpResponse = Context.Response;
httpResponse.Clear();
httpResponse.ContentType = "Image/Jpeg";
bitmap.Save(httpResponse.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
httpResponse.End();
}
catch (System.Exception e)
{
throw e;
}
finally
{
originalImage.Dispose();
bitmap.Dispose();
g.Dispose();
}
}
}

Use it like this:

<%@. Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
ImageMap1.ImageUrl = "Default25.aspx?oIP=C:\\Documents and Settings\\v-jyyin\\Desktop\\IMG\\c4960543c39f4f0c71b53bf27aa34e65.jpg";
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server" method="get">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:ImageMap ID="ImageMap1" runat="server">
</asp:ImageMap></div>
</form>
</body>
</html>

By the way,I don't think you can get the progress bar without ActiveX.