Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

Wednesday, March 28, 2012

Multiple Postbacks for AJAX

OK...I'm trying to think of the best solution for this situation:

I have an asp.net AJAX enabled website where the user can run complex queries off my SQL Server database. Some of these queries can last quite a few minutes to complete. What I want to happen is when the user clicks a button to run the query, the user can still move around the website while the query is running. And when the query is done, it basically alerts the user it is finished (by updating a label on the site, for example). So, I tried to do this in AJAX, but the problem is (as far as I understand it) is that, by default, the last postback takes precedence, so that if the user clicked another button after he clicked the run query button, the query can not post back to the site saying the query is done.

So I have a couple of questions:

1) Is there anyway for the site to respond asynchronsly to multiple postbacks?

2) If I make multiple postbacks, will all the calls still finish processing? Is it only that it can't post anything back to the server? For example, if the user ran a query that inserted rows into a table, and he clicked somewhere on the page, will the first postback still finish to completion?

3) Would any sort of multi-threading work in my example?

Thanks for any responses!!

-Howie

hello.

well, yes, you can, for instance, make several web service calls. you cannot do the same thing with an UpdatePanel since the last postback will, by default, cancel the previous one. what i think you should do is built some sort of queuing for packaging the client queries and sending them to the server. and i also think that you should use web services instead of updatepanels :)


Hi, thanks for the response. When you say that the last postback will cancel the previous ones, do you mean that it will cancel the query midway through? (excuse me if I'm being naive). Or do you mean that my code will still execute OK (that if the user wanted to insert rows into the table, that it will still do so without interruption), but I just can't post back a result to the site? Also, what do you mean I can make several web service calls? Would you be able to point me to a site I can read up more about it? (I know what web services are...I just don't know exaxtly what you'te referring to).

I really appreciate your help.

multiple update panels

hi every one..

i am using multiple update panels (more than 10) on a web page in my Ajax enabled asp.net website.

I would like to know whether it is feasible to use so many Update panels in a single form (one for each control which will go to server), or there is a possibility that i will face some problem due to it.

Any alternatives are also welcome.

thanx,

viraj

hello.

using several updatepanels might be a good approach if the zones wrapped by the panels should be refresed independently. in this case, setting the updatemode to conditional will result in reducing the size of the response returned from the server side. I'm not sure if there's any recommendation in the number of itens UpdatePanels that should be used in a page.


thanx...

Monday, March 26, 2012

My early adoption experiences.

Hi guys, this is my first post here.

I'm developing a Portuguese Travel Agency website, asp.net 2.0 powered backed by filemaker 7 server database.http://www.queroviagens.com is the original website without atlas features. I have atlas powered version herehttp://www.queroviagens.com/queroviagens/test.aspx with autocomplete in a textbox, and without postback having partial updates instead.

I have some triggers on 2 hidden buttons that make the choices, and in the javascript tree and other links i call a javascript function that puts in hidden textboxes the values of the selected Id's and make a button.click() so it can raise the event.

One thing i would like to do is to have distinct progressbars, one for each updatepanel, and not only one. Is it possible yet ?

Another thing: let's supose i want to update the javascript tree, and I have a webservice that returns the javascript code. I can inject that in a span but it will not load. Any javascript code is not executed. Any way to fix it ?

Thanks in advance, and happy coding

hello.

well, i'm assuming that you want 2 distinct progress bars so that the info message is different. if this is the case, you don't really need two bars since you can change what's shown with code similar to this one:

<%

@.PageLanguage="C#" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

scriptrunat="server">void h(object sender,EventArgs args)

{

info.Text = ((

Button)sender).ID +" " +DateTime.Now.ToString();

System.Threading.

Thread.Sleep(2000);

}

</

script>

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><atlas:ScriptManagerrunat="server"id="manager"EnablePartialRendering="true"></atlas:ScriptManager><atlas:UpdatePanelrunat="server"ID="panel"><ContentTemplate><asp:Buttonrunat="server"ID="bt"Text="Submit"OnClick="h"/><asp:Literalrunat="server"ID="info"/></ContentTemplate></atlas:UpdatePanel><atlas:UpdatePanelrunat="server"ID="UpdatePanel1"><ContentTemplate><asp:Buttonrunat="server"ID="bt2"Text="Submit"OnClick="h"/><asp:Literalrunat="server"ID="Literal1"/></ContentTemplate></atlas:UpdatePanel><atlas:updateprogressrunat="server"ID="prog1"><ProgressTemplate>

progress 1

</ProgressTemplate></atlas:updateprogress><scripttype="text/xml-script">

<page xmlns:script=

"http://schemas.microsoft.com/xml-script/2005">

<components>

<button id=

"bt">

<click>

<setProperty target=

"prog1" property="associatedElement" propertyKey="innerText" value="updatePanel1" />

</click>

</button>

<button id=

"bt2">

<click>

<setProperty target=

"prog1" property="associatedElement" propertyKey="innerText" value="updatePanel2" />

</click>

</button>

</components>

</page>

</script></form>

</

body>

</

html>
Totally off-topic reply but...

I like the javascript-powered treeview for the "Escolha o Destino" menu. Is it a third-party control or...?

Thanks,

-Benton
Hi Bento. Its a free javascript script:
http://www.softcomplex.com/products/tigra_menu_tree/

But in pageload I dynamic build the tree, with contents of database, and in the link item i put a javascript function i created EscolheDestino(123);

this EscolheDestino what it does is :

function EscolheDestino(val){

var t = document.getElementById('DestinoId');
t.value=val;
document.form1.btnEscolher.click();
}

So it puts the chosen Id in a hidden textbox field (DestinoId), and forces a hidden button (btnEscolher) to be clicked. This button is in the trigger of an update panel, and the datalist with the current offers for that destination are refreshed.

The problem I have is that the .click() does not raise the Click event on firefox. I will try change it to _dopostback() function to see if it fits.

Best regards

hello again.

sorry, i don't understand? what do you mean?


It's a free javascript available at:

http://www.softcomplex.com/products/tigra_menu_tree/

In pageload i dynamically generate the tree and in the link of each node i put a javscript function

EscolheDestino(id)

function EscolheDestino(val){

var t = document.getElementById('DestinoId');
t.value=val;

document.form1.btnEscolher.click();

}

What it does is selecting an id to a hidden textfield and simulate a click on a hidden button. This button is in a trigger that refreshes the datalist control.

The only problem is that this method of using .click() in firefox does not raise the Click event :|

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 using CollapsiblePanel

I tried looking at the sample website page and doing a search on the forums here.

I created a panel, put the panel in an updatepanel. but the collapsiblepanelextender inside the updatepanel as well. I set some overflow:hidden value on the style of the panel.

I load the page, I see the panel, then eventually it goes away, ok well that sucks anyway.

now what? I tried to create a button that would collapse/expand the panel but I'm not sure how.

I'm coding in VB and I looked at the C# sample web page and don't even see how they did it. All I see is if page is not postback, set panel to false and height to 0.

How do I control the collpasing and expanding with a button or whatever?

I tried on my button click but this but didn't work.

Protected

Sub Button1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles Button1.Click
Dim TargetPanelPropertiesAs AtlasControlToolkit.CollapsiblePanelProperties = CollapsiblePanelExtender1.GetTargetProperties(AddMemberPanel)If TargetPanelProperties.Collapsed =FalseThen
TargetPanelProperties.Collapsed =True
ElseIf TargetPanelProperties.Collapsed =TrueThen
TargetPanelProperties.Collapsed =False
EndIfEndSub

Ok, I got it somewhat working. I took out the code and pointed the property some controlID to my button. Wierd thing is though,

When I click my button it shows, but when I roll-over the panel it collapses again. Also when the page first loads it doesnt' collapse until I roll over it. what the hell?


Hi Mastro,

I'm not sure what you're doing wrong from your decsription. Perhaps you could post afull code sample.

Thanks,
Ted