Showing posts with label request. Show all posts
Showing posts with label request. Show all posts

Wednesday, March 28, 2012

Multiple UpdatePanel issue request at a same time

Hi all,

I have a page contains more than one UpdatePanel with different triggers and I followed the method here to handle multiple requests:

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

When one of the UpdatePanels has been triggered and refreshing, all the requests from other UpdatePanels in the page will be cancelled since prm.get_isInAsyncPostBack() returns true until the first request has been processed.

Are there any method to invoke multiple requests at the same time? Or else the user has to wait until the first request to be done before he/she can issue new requests with the other panels. I can accept the requests to be queued up and pending to be patched, but the PageRequestManager seems simply drops the previous or new requests depends on the implementation in the block:

if (prm.get_isInAsyncPostBack()) {
// drop new request or abort previous request
}

FYI, I found simliar post here:http://forums.asp.net/thread/1413005.aspx

Thank you.

HI Kylo,

I wondered the same thing. From all my reading, you can only send out one request at a time using the update panel. The only true asynchronous way to use asp.net AJAX is through web services. By default, the update seems to execute the latest request that was given and drop the previous.


Thanks for the reply, bebandit. In my case, I was converting a .NET 1.1 project to 2.0 to gain the benefit of easily adding ajax capabilities to the web application. UpdatePanel handles all ajax call, DOM manipulation and the UI rendering for me. If I have to write the client side web services call and UI refreshing HTML myself (not to mention to change some of the server side logic to web method as well), it would take too much development time and not worth to do in my business logic. Seem that I have to wait to see if there will be a truely "Asynchronous UpdatePanel" in the later release or I will look for the other AJAX libraries.


Thanks for the reply, bebandit. In my case, I was converting a .NET 1.1 project to 2.0 to gain the benefit of easily adding ajax capabilities to the web application. UpdatePanel handles all ajax call, DOM manipulation and the UI rendering for me. If I have to write the client side web services call and UI refreshing HTML myself (not to mention to change some of the server side logic to web method as well), it would take too much development time and not worth to do in my business logic. Seem that I have to wait to see if there will be a truely "Asynchronous UpdatePanel" in the future release or I will look for the other AJAX libraries.

Wednesday, March 21, 2012

Need help designing a drag-drop resulting in a formatted output to the user

Hi

I have a request from a customer regarding a drag-drop-edit feature.

This is the idea:

An editor of a website must enter data to show for the web-site user. He has a fixed number of elements that can be used, most of which will be positioned the same place on every page, but a few can vary and some can be added multiple times (this is decided based on the database using relations). The editor would like to be able to have some sort of toolbox feature on his "Create journal", from this toolbox he can drag out elements, such as date, journal number, description, resume etc. When an item is dragged out on the "workspace" he can then enter the data that should go in that field, meaning the description box should be considerebly larger than the date box as example. When the editor has added all the elements to the journal he can save it and it is now visible on the website. The website visitors can now see the journal formatted the way the editor defined it.

I haven't worked alot with AJAX before, so I would like to hear if this is something AJAX can help me solve? If so links to usefull sites would be very welcomeSmile

Hi,

Thank you for your post!

Seehttp://forums.asp.net/t/1187961.aspx

Here is a simple demo to combine pictures at server side in C#:

using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;

namespace Enter_name
{
class GenerateImage
{
public struct favoriteImage
{
private string _imagePath;
private int _x;
private int _y;

public int x
{
get
{
return _x;
}
set
{
_x = value;
}
}

public int y
{
get
{
return _y;
}
set
{
_y = value;
}
}

public string imagePath
{
get
{
return _imagePath;
}
set
{
_imagePath = value;
}
}
}

[STAThread]
static void Main(string[] args)
{
string CurrentDirectory = System.Environment.CurrentDirectory;
string body_path = CurrentDirectory + "\\4.jpg";

favoriteImage[] FaImage = new favoriteImage[2];

FaImage[0].x = -3;
FaImage[0].y = 70;
FaImage[0].imagePath = CurrentDirectory + "\\1.jpg";

FaImage[1].x = 20;//65;
FaImage[1].y = -12;
FaImage[1].imagePath = CurrentDirectory + "\\2.jpg";

generateWinterMark(CurrentDirectory, body_path, FaImage);
}

/// <summary>
///
/// </summary>
/// <param name="savePath"></param>
/// <param name="body_path"></param>
/// <param name="favorite"></param>
/// <returns></returns>
private static string generateWinterMark(string savePath, string body_path, favoriteImage[] favorite)
{
//create a image object containing the photograph to watermark
Bitmap imgPhoto = new Bitmap(body_path);
int phWidth = imgPhoto.Width;
int phHeight = imgPhoto.Height;


string nowTime = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
nowTime += DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();

string saveImagePath = savePath + "\\FA" + nowTime + ".jpg";

//create a Bitmap the Size of the original photograph
Bitmap bmPhoto = new Bitmap(phWidth, phHeight, PixelFormat.Format24bppRgb);
//setResolution
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);

//load the Bitmap into a Graphics object
Graphics grPhoto = Graphics.FromImage(bmPhoto);
//set the rendering quality for this Graphics object
grPhoto.SmoothingMode = SmoothingMode.AntiAlias;

for (int i = 0; i < favorite.Length; i++)
{
//Draws the photo Image object at original size to the graphics object.
grPhoto.DrawImage(
imgPhoto, // Photo Image object
new Rectangle(0, 0, phWidth, phHeight), // Rectangle structure
0, // x-coordinate of the portion of the source image to draw.
0, // y-coordinate of the portion of the source image to draw.
phWidth, // Width of the portion of the source image to draw.
phHeight, // Height of the portion of the source image to draw.
GraphicsUnit.Pixel); // Units of measure

//------------------
//Step #2 - Insert Property image,For example:hair,skirt,shoes etc.
//------------------
//create a image object containing the watermark
Bitmap imgWatermark = new Bitmap(favorite[i].imagePath);
int wmWidth = imgWatermark.Width;
int wmHeight = imgWatermark.Height;
imgWatermark.MakeTransparent(); //使默认的透明颜色对此 Bitmap 透明。


//Create a Bitmap based on the previously modified photograph Bitmap
Bitmap bmWatermark = new Bitmap(bmPhoto);

//bmWatermark.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
//Load this Bitmap into a new Graphic Object
Graphics grWatermark = Graphics.FromImage(bmWatermark);


int xPosOfWm = favorite[i].x;
int yPosOfWm = favorite[i].y;

//叠加
grWatermark.DrawImage(imgWatermark, new Rectangle(xPosOfWm, yPosOfWm, wmWidth, wmHeight), //Set the detination Position
0, // x-coordinate of the portion of the source image to draw.
0, // y-coordinate of the portion of the source image to draw.
wmWidth, // Watermark Width
wmHeight, // Watermark Height
GraphicsUnit.Pixel, // Unit of measurment
null); //ImageAttributes Object


//Replace the original photgraphs bitmap with the new Bitmap
imgPhoto = bmWatermark;//age(FromHbitmap(bmWatermark;

grWatermark.Dispose();
imgWatermark.Dispose();
}
bmPhoto.Dispose();
grPhoto.Dispose();

//save new image to file system.
imgPhoto.Save(saveImagePath, ImageFormat.Jpeg);
imgPhoto.Dispose();

return saveImagePath;
}
}
}

The demo show you that conbine 1.png and 2.png towhite.png.

Happy coding!

Need HELP with Ajax and Visual Studio 2003!

Dear guys,

Well i was tying to find what i need in this amazing forum, but as u can see, there are +4000 pages!

so i prefer to post the request and wish anyone of you can help please.

well i wondering if i can use Ajax with Visual Studio 2003. as the company iam working on still do not want change to 2005 version of VB cause their website can not work with the 2005!!

anyway, is there a way i can make them work together, Ajax with VB.NET 2003? and what should i instal?

thanks very much in advanceSmile

Hi,

ASP.NET AJAX, the server controls like UpdatePanel, need .NET 2.0, which isn't supported in VS.NET 2003.

However you can also grab the Microsoft AJAX library, which are only the client side .js scripts that you can use. They also can be used in conjunction with PHP for example so it should also work with .NET 1.x webservices:http://smarx.com/posts/php-for-microsoft-ajax-library.aspx.

Grz, Kris.


Cheers mate,

well i will try to check on google ... but as i said, its the comapany website, and they using VB.NET and ASPX so i can not use PHP, i think even their server dont support PHPTongue Tied but still thanks a lot


hello.

well, the microsoft ajax library contains only client js files. this means that you can use them from whatever platform you want. take into attention that the library contains only client utilities. the server side controls can only be used from asp.net 2.0 sites.


Hi,

Zaid Amer:

so i can not use PHP, i think even their server dont support PHP

after rereading my former reply I noticed also that it could be misread, sorry for that. I meant indeed that the client scripts can be reused but only the server controls run on .NET 2.0.

Grz, Kris.


Thanks man,

really helped alot, yeah i got it now ... actually didnt know that will work, that will be great if it does, coz ioam sure the erver side run .NET 2.0

thanks againfor the fast reply

Zaid


Hi,

Zaid Amer:

coz ioam sure the erver side run .NET 2.0

if it runs .NET 2.0 you could install the Extensions and have your webservice decorated with the [ScriptService] attribute. In your ASP.NET 1.x application you can then use only the client side scripts (called Microsoft AJAX Library) to AJAXy call the webservices. Just an idea.

Grz, Kris.