Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Wednesday, March 28, 2012

Accordian - Smooth at first, then gets choppy

Here's what I have. I've got an accordian in a web user control. And I've placed it on all my pages. When I go to the first page it runs VERY smooth.. but once I click on a link from the accordian to another page.. the refreshed accordian user control is all choppy.

I also tried this with a datagrid in an update panel as a user control and it did the same thing. So I know it's not the accordian. It has something to do with atlas. I compared the source from a smooth page and a choppy page and there's no difference..

so what do I have to do to keep it smooth? or can you not use it as a web user control?

Apparently.. it's all IE6's fault.. ugh that really sucks.. I don't know if I can get the whole company to upgrade to IE 7 Beta 3.. stupid flickering..
Hi unlikelyband,

Did you discover a specific reason IE6 was causing this? Or is it just only IE6 that it happens in?

Thanks,
Ted

Well. I actually only tried IE 6 and IE 7 Beta 3.. and IE 7 is really smooth..

I don't really have time to text IE 5 or opera or firefox..

All I know is that it kind of sucks people are going to have to deal with the flicker until they manage to upgrade everyone to IE 7


Hi,

Well it's true that the animation in IE6 isn't as smooth as IE7 and Firefox, but we're working on making the accordion snappier. Hopefully it won't be a problem for you and your users after the next release.

Thanks,
Ted

Accessing the ScriptManager in code behind

In a User Control, how do you access the ScriptManager in code behind? The ScriptManager gets placed on the "parent" aspx page, but seems not to be accessible from any user controls ascx that get added to that page.

Specifically, I would like to capture the ScriptManager.PreRender event for use in a Repeater control.

Is there a way to raise an event in the parent ASPX page that the child user control can pick up?

if you want to call parent control,

you can use

this.Parent.FindControl..

i am not sure why you want user control to do something with "ScriptManager.PreRender event"

why cant you use ScriptManager.PreRender event to do something for your user control ?

you can always use

Page.FindControl to call your use control in the ScriptManager.PreRender event


Hey, thanks for your reply. I could really use some help.

The goal is to use an update panel inside a repeater, both of which are use controls loaded onto a page. There are some inherint challenges with this. The first being that 1) the ScriptManager is not accessible because it is in the parent, 2) the update panel elements don't seem available at the time of the event. Below is my code to access them, but the me.parent.findcontrol always returns "nothing."

My research has shown me that the ScriptManager.PreRender is the event that I can access/ change these values.

My entire page works great, except the update panel inside the repeater does not update and I cannot access the objects within it (i,e, a label)

Sub handleTypeTest(ByVal senderAs System.Object,ByVal eAs System.EventArgs)

Try

Dim tempVAsString = ddlAnswerType.SelectedValue

ddlAnswerType.Visible =False

Dim tempUPAs UpdatePanel =Me.Parent.FindControl("upDropDowns")

IfNot tempUPIsNothingThen tempUP.Update()

Dim tempLabelAs Label =CType(Me.Parent.FindControl("lblTest"), Label)

tempLabel.Text ="changed"

Catch exAs Exception

EndTry

EndSub

Accessing PopupControl methods from client script

Hi,

How can I access the client-side functions of the PopupControl (namely "hide()")? Rather than the user having to click elsewhere on the page I also want to have a close button. According to the Firebug DOM explorer, the div element thats used for the popup has a property "PopupBehaviour" but trying to access this throws an error.

Cheers

Hi,

Not sure if this is the "correct" way to do this but I do this:

ButtonClose.Attributes.Add("OnClick","__AjaxControlToolkit_PopupControlBehavior_VisiblePopup.hidePopup();");

HTH

Jeff


I'm running into the same problem. I want to do a client-side close of the popupcontrol. I tried getting the uniqueid of the panel that's being popped up and setting the .style.display property to 'none' and that closes the panel but the problem is that whatever controls the panel used to cover are disabled. They've done this on purpose to disable controls from underneath the overlayed panel from being selected while you are selecting controls on the panel. So my solution half works.

Does anyone in the ASP team or someone who's had a need to close the popupcontrol control on the client-side have a clean a proper solution for this? Doing a postback to close the extender is a really stupid way of closing it so I'm sure someone must have come across this... Thanks!


Hi,

In version 1.0.10123.0 of the toolkit i do this on the client side which seems to work, as I said before I'm not sure if this is the correct way but it works.

AjaxControlToolkit.PopupControlBehavior.__VisiblePopup.hidePopup();
hth
Jeff 

I found this nice free popupcontrol. It comes with full source and also the .dll. Its nice to have this control in your Visual Studio Toolbox. ;)

Dainty Date


Jeff, thanks that works.


Cool. I will try that. Currently I use a button that calls "document.body.click()" to simulate the clicking elsewhere outside of the popup which effectively closes it.

Hi,

The easeist way to do this is add a BehaviorID="MyPopup" on the extender and then usevar behavior = $find('MyPopup'); in script.

Thanks,
Ted

Accessing Masterpage Ajax control from Web user control

Hi all,

I have created a master page in asp2.0 and i have placed ModalPopupExtender in that. I have written a custom Textbox control. In that text Changeded event i have created reference to the Masterpage modalpopupextender using Findcontrrol method. But i cant able to loop through tge Master page controls Properly. I am unable to findthe controls with its client id. Can anybody know how to solv this.

My aim is to call the modalpopupextender show event from the custom control.

<cc1:ModalPopupExtenderID="ModalPopupExtender1"runat="server"TargetControlID="btnForLookup"PopupControlID="LookupPanel"BackgroundCssClass="modalBackground">

Private

Sub AHNLookup_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Click

{ Dim contr as ModalpopupExtender

Contr = Me.page.master.FindControls("ModalPopupExtender1")

Constr.show() -->Gives error as Null object.

}

====

Thanks in advance.

S.Sathishraja

Hi,

Please try to find it in a recursive way.

public?Control FindControlRecursive(Control root, string id)
{
????if (root.ID == id)
????{
????????return root;
????}

????foreach (Control c in root.Controls)
????{
????????Control t = FindControlRecursive(c, id);
????????if (t != null)
????????{
????????????return t;
????????}
????}

????return null;
}
Hope this helps.

Accessing controls inside an updatepanel in onPreInit event

I have an update panel inside a user control that is initialized during the page's PreInit event. However, as soon as I put an updatepanel inside this user control I can no longer access the controls inside this updatepanel during the PreInit event. The controls are all just "null". Am I doing something wrong, or does the updatepanel somehow change my ability to access these controls?Thanks,Jon

Set a breakpoint in PreInit and step through the PageLifeCycle then you see in what Event the UpdatePanel get initialized.


I was just wondering why putting an updatepanel in would break my existing code? Shouldn't it get initialized at the same time as the other controls?
Please have a look at Wally'sPodcast about the clientside lifecycle. I think he's awnsering youre questions.

Monday, March 26, 2012

Accessing AJAX.NET app as part of ASP application

I have written a ASP.NET appliacation named IIC with AJAX features for filling the GridView without refreshing the page when user filters data by using dropdowns and checkboxes. The application is working fine when I run it indepently as follows:

http://localhost/IIC/default.aspx

But this application needs to be the part of our existing ASP application called "Aspapp". So I moved my AJAX enabled ASP.NET application folder as sub folder to ASP application and accessing the page using the following URL:

http://localhost/Aspapp/IIC/default.aspx

Now everything works fine, but except the AJAX. The page refreshes when I fill the GridView.

I copied AjaxControlToolkit.dll and other ASP.NET application related dlls to the bin folder of "Aspapp/bin" application and also "Aspapp/IIC/bin" folder.

I have checked the IIS settings, so that the application is configured to run using .NET 2.0 framework.

My questions are:

1. Am I missing any other assemblies related to AJAX to be copied?

2. Am I copying the assemblies to the right folder?

3. Am I missing any IIS configuration?

Please help.

In IIS make the create a IIC virtual directory. This will cause IIC to run as an independent application and should allow the AJAX to work.


Thanks aquillin.

I fixed the problem. I noticed a javascript error "'Sys' is undefined" is thrown on my ASP.NET page in the ASP application. Then I did research on this error and found a usefull link on the net http://weblogs.asp.net/chrisri/archive/2007/02/02/demystifying-sys-is-undefined.aspx and came to know that its the problem in the web.config file.

I supposed to add the AJAX specific entries to the web.config file. But the new issue was the ASP.NET application works indepently and I didn't made any changes to it while copying it as a sub folder for ASP application. After little research on the ASP applicatoin I found that there is another web.config directly under the /AspApp folder. So copied the <System.web.extensions> and other AJAX specific configurations to /Aspapp/web.config from /Aspapp/IIC/web.config and everything started working fine.

Access User Controls in Web Service

Hello all,

We have a custom control that has many custom properties and methods. Currently this control is being loaded through the Master page and it is working just fine. Now there is a need to load this control through a web service.

Since the control needs to be loaded through a web service, the web service does not have any information on this custom control and its properties/methods. We can only load this custom control as a System.Web.UI.UserControl, and we cannot also cast this UserControl as a custom control because the web service does not know anything about this custom control.

I read this article about rendering user controls through web service by Scott Gutherie but it only talks about user control and not custom controls and custom properties and methods.

http://weblogs.asp.net/scottgu/archive/2006/10/22/Tip_2F00_Trick_3A00_-Cool-UI-Templating-Technique-to-use-with-ASP.NET-AJAX-for-non_2D00_UpdatePanel-scenarios.aspx

Does anybody have any ideas on how to access the custom control in a web service?

Thanks.

Hi,

For custom control, it's necessary to add reference to it in the web application. And instantiate it with its actual constructor.

Then, you may render it in a similar way as Scott Gutherie has shown.

Access control on MasterPage from within content page

Hi all,

I have a MasterPage with invisible Label.

In content page I have a few controls and any Button.

When user clicks the Button, the Label on MasterPage appears.

So far - so good.

If I use an UpdatePanel inside the content page, the Label stay invisibleSad.

I know, that it's right behavior for Ajax enabled application, but...

What is the solution?

MasterPage:

<%@dotnet.itags.org. Master Language="C#" AutoEventWireup="true" CodeFile="TestMasterPage.master.cs" Inherits="TestMasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> <asp:Label ID="Label1" runat="server" Text="Error!" Visible="False"/> </form></body></html>

Content page:

<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/TestMasterPage.master" AutoEventWireup="true" CodeFile="TestContentPage.aspx.cs" Inherits="TestContentPage" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ListBox ID="ListBox1" runat="server"> <asp:ListItem Value="1">Item 1</asp:ListItem> <asp:ListItem Value="2">Item 2</asp:ListItem> <asp:ListItem Value="3">Item 3</asp:ListItem> <asp:ListItem Value="4">Item 4</asp:ListItem> </asp:ListBox> <br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </ContentTemplate> </asp:UpdatePanel></asp:Content>

Content page code behind:

protected void Button1_Click(object sender, EventArgs e) {//Do something... //... Label lbl = (Label)Page.Master.FindControl("Label1");if (lbl !=null) lbl.Visible =true; }

The solution: enclose the Label on the MasterPage by UpdatePanel:

<%@. Master Language="C#" AutoEventWireup="true" CodeFile="TestMasterPage.master.cs" Inherits="TestMasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"/> <asp:UpdatePanel ID="updatePanel2" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="Error!" Visible="False"/> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Saturday, March 24, 2012

about ScriptManager

if there was a user control (ascx) which have a ScriptManager control in a page(aspx), would there need a ScriptManager in my page?

about master page?? if have a ScriptManager control , how can i deal with its son page?

thankyou

Hi,

you can only have one ScriptManager control. My suggestion is to put it in your page (or in the master page). If you need to add scripts or services references in user controls, you can use the ScriptManagerProxy control.

I think you're getting a sense for the awkwardness of the current implmentation.

If you'd like, you can help me recommend a more elegant solution by contributing here:

http://forums.asp.net/thread/1364014.aspx

Abort aysnc request when user clicks a menu link on the web page

Hi,

I've got my web page working with ASP.NET AJAX but the problem is when I click a link on pages menu I don't get taken to the new page until the page I'm on has received all the async. data from the server.

So, I need to know how to abort the async. requests when the menu link is clicked so it takes me straight to the newly requested page.


Thanks
Jon

You may want to look at the update progress. I think the at least the older releases had a way to do that there.
Hi,

You can use the following javascript function to abort an async call.

function CancelAsyncPostBack()
{
Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
}

Hope this helps.

Hi,

Just to test this, I added button to my page which calls the Cancel javascript function. After clicking this button I then click one of the menu links and I don't get taken to the new page until the AJAX stuff has finished.

Below provides more information and hopefully clarifies what I'm doing.


1) On page load a javascript function is called which loops through each row in the DataList table and makes an asynchronous call to a webservice method on the server.

2) It takes 10-20 seconds for the server to calculate the details for each request and then return the results to the callback function on the client, where the results get shown in appropriate columns of the DataList table.


I have 10 rows in my table so end up making 10 near simultaneous calls to the webservice on the server. Whilst waiting for the server to finish responding to these requests I click a link on the page and I want to be taken to the new page immediately. As it stands, I have to wait for the server to respond with all the requested data.


So, my questions are:

1) how do I stop the client waiting for the rest of the data so it goes to the new page?

2) Is it possible to tell the webservice on the server to quit working on the problem?

Thanks
Jon



The reason is because of theInternet Explorer's Simultaneous Connections Limit which is 2 by default.
Please refer to this: ?http://weblogs.asp.net/mschwarz/archive/2005/10/20/428047.aspx

speedbird:

?1) how do I stop the client waiting for the rest of the data so it goes to the new page?

2) Is it possible to tell the webservice on the server to quit working on the problem?

As far as I can tell, there isn't a good way to achieve your requirement.

Hello,

Q) how do I stop the client waiting for the rest of the data so it goes to the new page?
A) What you can do is use JavaScript or HTML anchor to redirect the client to a different page.

Sample: HTML Anchor: <a href=URL_Name target="_self">Click to go to different page</a>

JavaScript Function
function Redirect()
{
location.href='http://www.asp.net';
}

<asp:hyperlink id="hlRedirect" Text="Click Link to Go" onclick="Redirect(); return false;" style="cursor: hand;" runat="server" />

Sample URL:http://forums.advancemicrotech.com/threads/thread051507.aspx
Note: The Start Thread button is the same as your webservice doing its job. Once you click Start Thread button, the thread goes to sleep for 10 seconds, same as your webservice doing something on the server. During this time, you can either click the Redirect button that is created with HTML or the ASP Hyperlink ... as shown above ...


Q) Is it possible to tell the webservice on the server to quit working on the problem?
A) No you cannot tell the webservice to quit working while it's doing its job.

Hope these help ... Cheers.

Abort AJAX Postback

Hello,

I am developing a project, which has many things on admin and merchant side, but very less on user site.

The user site contains a page from where user can search the data. This is the main page on user site.

The search page contains 10 sliders and 6 different parameters which are checkboxlist. There are at least 5, 00,000 records in the database.

I am using database paging to get result fast.

I am using AJAX on this page.

Now the problem is that when ever I move the slider and release it then button click event is called from JavaScript.

I have 10 sliders on the page now when I move all the sliders one by one the page becomes very slow. It performs all the post backs in the queue.

Is there any way from which I can cancel the previous post back if the page is already inasynchronous postback.

I have even tried the following code when the user moves the slider; I call the following function;

function StopPostBack()

{

var CheckPostBack = Sys.WebForms.PageRequestManager.getInstance();

if (CheckPostBack.get_isInAsyncPostBack())

{

CheckPostBack.abortPostBack();

}

}

But this too not helped me much.

I think the problem is that when ever user moves the first slider and release it the button click event is called and in that the stored procedure is called to fetch the data.

Now when user move another slider the function StopPostBack is called but till that time the application has started the database operation.

My stored procedure taking less then 2 sec to return the data. But when there are multiple movements of the slider the page is very slow.

How can I make is fast.

Regards,

Deepesh Verma

Hi Deepesh,

Please refer to this thread, http://forums.asp.net/thread/1695055.aspx
There is no easy way to abort the execution on the server from the client.
I think you need to find a way to reduce the occurrence of postback on the client.

Wednesday, March 21, 2012

A problem when I use script manager, script manager proxy

I have an default.aspx and 3 link in that page. When I click to one of these links I want to load a usercontrol( ex: control1.ascx ) and in this user control I also use ajax in this control. Other Developer said that I must use a master page and declare a script manager in this page. In usercontrol I just need to use scriptmanagerproxy... But I don't know exactly what I have to do. Can you help me. Thanks all of you a lot.

Hi hamanhtuan,

Well the scriptmanagerproxy is an extended version of the scriptmanager. In your situation i think you can fix it with just a scriptmanager on your .aspx page and no scriptmanagerproxy on the user control. When your webpage contains a scriptmanager control and the usercontrol isn't you can still make use of the Ajax functionalities. keep in mind that when you deploy this usercontrol on an apsx page where you're not have a scriptmanager then it isn't working. The scriptmanagerproxy isn't a solution for this problem because the scriptmanagerproxy also needs a scriptmanager control. So drop a scriptmanager on your aspx page and other controls (Updatepanels) in your usercontrol and it will work. Hope it helps.

Regards


When I remove a scriptmanagerproxy on my controls and use Updatepanels in my usercontrol then my *.aspx can load these control. But in my control, I have a gridview, a refresh button and I want to auto update this gridview when click this button. How can I do this work ? Thank you for your last answer.

Hi hamanhtuan,

SO your gridview needs to be in the updatepanel and the button should be the trigger for the updatepanel. this will partial update the controls inside the update panel but take a look at the following:

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.


Thank you for your answers.

A form, a treeview, a update panel, and required field validator.

Ok. Lets see if I can explain this. I have a treeview in a uppdate panel. It has an "Add User" node and some "Users" nodes uder it(Siblings). I have a "Add/Edit User" form in the page, inside a panel inside a update panel. This form has a submit command button and the fields have required field validators. These validators are in a ValidationGroup with the submit button. It''s set up so that when a user clicks the "Add User" node, the form panel is made visible so that a new user can be added. When you click on a particular users node, the users information is loaded into the fields and the panel is set to visible so you can edit the users information.


Here's the issue:

When you select the "Add User" node on the tree the blank fields load and all is good. If after that you click on a users node, the users info is loaded into the fields as it should, and that update panel is updated, but all the validators fire. So, selecting a node in the treeview causes the validation to fire even though they are grouped with the Submit button. I expected the validation grouping would solve the issue, but it didn't. Now I'm stumped. Just staring at it.?Any ideas? Anyone?


Thanks,

CL

One issue could be that treeviews aren't supported in updatepanels... We have noticed some strange issues when we were trying to get one work. You may also want to make sure that everything else has causes validation set to false.
Thanks for your reply. I'll look into the causes validation thing and see if that works.
mdenn, you're a dang genius. That worked. Thanks a bunch.

a first-day atlas user got this error, HELP!

when i following the basic atlas application from the following link, btw, I didn't use visual studio, I just manually do it from text editor and command line compiler.

http://atlas.asp.net/docs/Walkthroughs/GetStarted/Basic.aspx

I got a "syntax error" when I launched the page. then when i input text and pressed button, I got "sample undefined" error and nothing happen.

This is the log :

2006-06-29 20:21:18 192.168.1.1 - 192.168.1.36 80 GET /AtlasScript.aspx - 200 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727) -
2006-06-29 20:21:19 192.168.1.1 - 192.168.1.36 80 GET /WebResource.axd d=-qnjsxFIQPRe60N1ywfq1ZGbOVMGC5TKMX4JTqrXTR7atJCaMTR4Fc76IpI0uvmBTmmGba1jsr6v9f3MrKscIivr3HdGL-IH8Yqrm9oH01I1&t=632799165960000000 200 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727)http://www.mydomain.com/AtlasScript.aspx
2006-06-29 20:21:19 192.168.1.1 - 192.168.1.36 80 GET /HelloWorldService.asmx - 302 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727)http://www.mydomain.com/AtlasScript.aspx
2006-06-29 20:21:19 192.168.1.1 - 192.168.1.36 80 GET /ErrorPage.aspx aspxerrorpath=/HelloWorldService.asmx/js 200 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727)http://www.mydomain.com/AtlasScript.aspx

hello.

can you be more specific about the error? is it a script error?


yes, it's a script error from browser(IE)

hello again.

well, where are you getting it? what does the error message say? where does it stop in the debugger? what's your code? without knowing this we won't be able to help you.


PROBLEM solved, I followed the installation instruction to modify web.config, it failed, buy when I copied the web.config from atlas folder, it works now!

Thank you very much!

A extended thinking from Atlas

today when I study Atlas , suddenly a thinking pop up , since atlas is used for user can retrieve data from client side directly , could we do the whole web page work like this ?
what I mean is we can retrieve the html part also by client script , so we can seperate the page into several parts , every part html can be retrieved independaly , and also the data part still retrive as Ajax doing now . so we can unify our page working style , we can retrive the whole html page framework , or retrieve one or more parts of the html page at a time , and also can retrive any data part of the page . As a result the whole web application always hold a unique url which is this app 's domain , and the url in address will not changed , what we request the web page is done in the page by client side operation , and just comminucate with web server what we need , either html markups or xml datas .

what do you think of this ? of course this is just a suddenly idea , without any deeply thinking and detail realization .

Wouldnt that be what frames provide?
Yes, this is possible ... and is often called the "single page application" model, that is becoming a viable option with AJAX techniques. You'll want to be careful about user model though, and there are some places where regular link navigation is still useful (eg. to be able to bookmark specific content).

90 seconds delay for posting back to the server when user clicks the abortButton

Hi,

In my application, I have an UpdateProgress control with an abortButton. I hook the Onclick attribute of this button to a server-side method.

When the application does not contain a global.asax file, all is working perfectly: When the user click on the abortButton, it posts back immediately.

But, when the application contains a global.asax file, there is a delay of approximatively 90 seconds between the user's click of the abortButton and the execution of the method in the server-side.

Here's a little exemple how to reproduce the problem:

aspx page:

<%

@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default" %>
<%@dotnet.itags.org.RegisterAssembly="Microsoft.Web.Atlas"Namespace="Microsoft.Web.UI"TagPrefix="cc1" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server">
<title>Untitled Page</title>
</head>
<body>
<formid="form1"runat="server">
<div>
<cc1:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="True">
</cc1:ScriptManager>
</div>
<cc1:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:ButtonID="Button1"runat="server"OnClick="Button1_Click"Text="Button"/>
<asp:LabelID="lblResultat"runat="server"Text="Label"></asp:Label>
</ContentTemplate>
</cc1:UpdatePanel>
<cc1:UpdateProgressID="UpdateProgress1"runat="server">
<ProgressTemplate>
Contacting server... <br/><br/>
<asp:buttonid="abortButton"runat="server"OnClick="abortButton_ServerClick"Text="Abort Request"/>
</ProgressTemplate>
</cc1:UpdateProgress>
</form>
</body>

Code behind:

using

System;
using System.Data;
using System.Configuration;
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;
using System.Threading;
using System.ComponentModel;
using System.Net;

public

partialclass_Default : System.Web.UI.Page
{
privateEventWaitHandle ewhWait =newEventWaitHandle(false,EventResetMode.ManualReset);

protectedvoid Page_Load(object sender,EventArgs e)
{
}

protectedvoid Button1_Click(object sender,EventArgs e)
{
Thread thread =newThread(newThreadStart(ThreadLong));
thread.Start();
ewhWait.WaitOne();
lblResultat.Text ="End of lengthy method";
}

publicvoid ThreadLong()
{
Thread.Sleep(100000);
ewhWait.Set();
}

protectedvoid abortButton_ServerClick(object sender,EventArgs e)
{
ewhWait.Set();
}
}

Global.asax

<%

@dotnet.itags.org.ApplicationLanguage="C#" %>
<scriptrunat="server">
void Application_Start(object sender,EventArgs e)
{
// Code that runs on application startup
}void Application_End(object sender,EventArgs e)
{
// Code that runs on application shutdown
}void Application_Error(object sender,EventArgs e)
{
// Code that runs when an unhandled error occurs
}void Session_Start(object sender,EventArgs e)
{
// Code that runs when a new session is started
}void Session_End(object sender,EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>

To Reproduce the problem:

1- put a breakpoint in theabortButton_ServerClick method
2- Execute the application and clickButton1
3- clickAbort Request
4- after 90 seconds, the application breaks.
5- Remove Global.asax from the solution
6- Execute the application and clickButton1
7- clickAbort Request
8- the application breaks immediately.

This delay appends also under different conditions; I explained the Global.asax case because it is the easiest to reproduce.

Is there someone knowing the reason of this behavior?

How can I force a postback of the abortButton ?

Thank you for any input .

Well it looks like you have gone to quite a bit of trouble just to get an abortButton cancel the current requests. I hate to tell you but there is a much easier way to abort requests. Atlas has a special button called abortButton (go figure). So basically the atlas framework looks for a button event with the id of abortButton. You don't have to create some custom method to cancel the request the atlas framework handles it, and it works great. Below is all you have to put into the UpdateProgress template and you will be set. At least now you have some really cool code to shutdown events :). By the way when you press the button it doesn't force a postback it just ends the request.

<

inputid="abortButton"type="button"runat="server"value="Stop"/
Have fun!

JoeWeb


Hi JoeWeb.

Thanks for your quick reply.

I am using the Atlas abortButton.
I don't think it's matter if it is a "input type=button" or a asp:button, both are translate by Atlas like this :

<button id="UpdateProgress1_abortButton">
<click>
<invokeMethod target="_PageRequestManager" method="abortPostBack" />
</click>
</button>

But just to be sure, I try this button

<input id="abortButton" runat="server" type="button" value="Stop" onclick="AbortRequest()" />

and in the javascript AbortRequest() I call the server via anICallbackEventHandler method.

Atlas is doing a great job cancelling the request on the client side. The problem is that it does not cancel it on the server-side, the methode is still running.
You can verify that by placing a breakpoint in a long request. Even if you cancel it, the breakpoint will eventually be hit.

In my application, if somebody cancel the request I have some cleanup to do. So, if somebody cancels with the abortButton, the server must be inform in some way.

I also notice that if you cancel a request and re-submit it immediately, Atlas waits 90 seconds before posting it to the server.


Don't know what to tell you then. The application we have using atlas handles about 15 million records in a database for tons and tons of customers and it handles requests just fine. Haven't had any problems with it taking longer to send a request right after aborting it. We serve alot of data back and forth and it handles the request no problem. Sorry, don't know what to tell you.

Good luck.

JoeWeb


I finally pin-pointed the problem with the Atlas abort button.

I was wrong when I said that there was no request to the server when the Abort Button is clicked.
I traced Global.asax and I found out that the BeginRequest event is triggered.

The problem is with the creation of the handler between the ResolveRequestCache event and the AcquireRequestState event; this operation takes almost two minutes to complete.

I don't know why it tooks so long. For other request than the Abort Button it's very fast.

Am I the only one to have this problem ?