Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Wednesday, March 28, 2012

Multiple Timers and Multiple UpdatePanels

I am creating a page with many different server controls that each need to automatically refresh independently. I want the developer to be able to specify the refresh time, so I am exposing that as a property of the control. The problem is, whenever the first timer ticks, all the other timers reset (and the label control in each UpdatePanel updates with the current time) even though they are on different intervals. It acts like all the UpdatePanels are posting back, but I know the tick event is only firing on the first timer (the one with the lowest interval). Any ideas as to what's happening here or what I'm doing wrong?

Here is my (raw, not refactored) code (CreateChildControls method):

If AutoUpdateThen Dim panelAs UpdatePanel =New UpdatePanel()Dim progressAs UpdateProgress =New UpdateProgress() _label =New WebControls.Label()Dim timerAs Timer =New System.Web.UI.Timer() panel.ID =Me.ID +"_UpdatePanel" panel.ChildrenAsTriggers =True panel.UpdateMode = UpdatePanelUpdateMode.Conditional timer.ID = panel.ID +"_RefreshTimer"#If DEBUG Then timer.Interval = IIf(RefreshSeconds <> 0, RefreshSeconds, _refreshMinutes)#Else timer.Interval = _refreshMinutes#End If AddHandler timer.Tick,AddressOf OnTimerTick panel.ContentTemplateContainer.Controls.Add(timer) _label.Text =String.Format("Updated at: {0}", DateTime.Now) panel.ContentTemplateContainer.Controls.Add(control) panel.ContentTemplateContainer.Controls.Add(_label) control = panelEnd If
I've also tried creating the timers outside the UpdatePanels and adding an ASyncPostBack trigger on the Tick event of each timer like so:
 
If AutoUpdateThen Dim panelAs UpdatePanel =New UpdatePanel()Dim progressAs UpdateProgress =New UpdateProgress()Dim timerTriggerAs New AsyncPostBackTrigger() _label =New WebControls.Label()Dim timerAs Timer =New System.Web.UI.Timer() panel.ID =Me.ID +"_UpdatePanel" panel.ChildrenAsTriggers =False panel.UpdateMode = UpdatePanelUpdateMode.Conditional timer.ID = panel.ID +"_RefreshTimer"#If DEBUG Then timer.Interval = IIf(RefreshSeconds <> 0, RefreshSeconds, _refreshMinutes)#Else timer.Interval = _refreshMinutes#End If timerTrigger.ControlID = timer.ID timerTrigger.EventName ="Tick" Controls.Add(timer) panel.Triggers.Add(timerTrigger) _label.Text =String.Format("Updated at: {0}", DateTime.Now) panel.ContentTemplateContainer.Controls.Add(control) panel.ContentTemplateContainer.Controls.Add(_label) control = panelEnd If
Thanks! 

D'oh!


A detail I had failed to mention previously was that these update panels are contained within a surrounding update panel. This panel was set to UpdateMode = Always, which was causing all of the UpdatePanels inside of it to automatically update. I set it to conditional and it seems to work fine now.

-Joe

Monday, March 26, 2012

Multiple XmlHttpRequest

Hi All,

I am new in Ajax Web Technologies. But want to learn deeply. Currently I am trying to develop a web application which reports ISA Server logs according to our needs.For example, I am fetching a dataset from SQL server and displaying them on a table. As soon as page loaded, I am executing Ajax functions which resolve host name from IP address. As you can imagine the result of query is more than 300 rows. So, resolving IP addresses one by one for 300 rows takes too long time and it is not desirable. In order to handle this problem I used Ajax library that I found onhttp://www.szajkowski.com/ajaxsample.html . It is pretty good. It creates multiple xmlhttprequests at same time. And its object handles are being stored separately. So no overwritten requests.

But the problem is, because of the limitations of IE and even Firefox, only two XmlHttpRequests are permitted for requests which points to same domain. As I learnt, it was possible to increase this value by modifying registry settings. But I don't want to do it.

I wondering that is it possible to make many simultaneous Ajax requests by using Web service methods? In XmlHttpRequest If I use POST in stead of GET.

Or is there any other way to be able to accomplish it?

Thanks in advance for your helps.

As far as I know, unless you're using some kind of IFrame-based hack, all the methods you describe are still using XmlHttpRequest objects 'under the hood'.

However, I'd argue that 2 is enough at any given time. Consider paging and chaining calls. For example, let's say that you want 50 items per page. You fire off two ajax calls, and those calls return with the 50 records plus information about which page they are and what the total number of pages is. Your 'OnRequestSuccess' handler on the clientside inspects that information in additon to parsing the data into your page, it decides if there's more data to be gotten, and fires off a request for the next page. You'd probably want to add in some logic to make sure you're not grabbing the same page twice and the like as well, but that's the basic idea. Figure that it'll take the user at least a few seconds to look at each page of data, and even if that's not quite enough time for the next batch to come down, you should be at least one page ahead of him at all times.

paul


Hi Paul,

You are right. I did some modification on server-side code.Now, I am using just one XmlHttpRequest and sending all IPs at once. And in server-side code, I used multi threaded DNS queries. And after all threads exits, it sends the all results together at once.

Thank you very much for your interest and valuable comments.

Ilhan

My ASP.Net Ajax dont work with my localhost server

when i test my ajax page in visual studio debuger , working without any problem ,

but when i try to use in my localhost server, the page cause postback , why

I tested Ajax website in my PC and found it works.But if you specify?asp:PostBack?not?asp:AsyncPostBack,there?will?be?the?
whole?web?page?post?back.

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 :|

my err on server - please

what to do?? and what is it?? - i am a biginer..

Description:An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message:Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. (d:\webspace\ADMIN\yanivsplace.com\WWW\web.config line 52)

Source Error:

Line 50: </httpHandlers>Line 51: <httpModules>Line 52: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>Line 53: </httpModules>Line 54: </system.web>


Hi,

and welcome to the ASP.NET forums.

Did you install the ASP.NET AJAX Extensions properly on your computer (http://ajax.asp.net/downloads/default.aspx?tabid=47)?

Grz, Kris.


Thank you for welcomingAnd yes I did installedASP.NET AJAX Extensions Now on my machine there is no problems – its runs..

But when I tried to upload the files to ftp I got this problem


y4all:

on my machine there is no problems – its runs..

But when I tried to upload the files to ftp I got this problem

Does the server where you ftp'ed your files to also have the extensions installed as well?

Grz, Kris.


I hade my doubts but is the first time that I try to upload files to a server –

thanx


Hi,

y4all:

I try to upload files to a server

The AJAX extensions must be installed by your hosting company on their server. Not by you. If you have any doubts regarding that, contact their help desk to make sure they've installed it or going to install it.

Grz, Kris.


Yes they do supportAjax

thanks


Add a reference to system.web.extensions or system.web in your project.. this will solve the issue..right click "bin" click "Add reference" in .NET tab there will select system.web or system.web.extensions or both...


first thak you.

so first I didn't had a bin folder – so I added 1 (asp:bin folder) then I did select thereferences and clicked ok but files where added to the bin – the folder was empty

Saturday, March 24, 2012

need a soap tools

dear sir,

I want to know which tools can be used to catch soap inforamtion? I used tcpmonitor, but it is better when client and server at differnt host.

thanks

SOAPSonar is an excellent tool and they have a free version that you can download.

need help about socket programming

hello ,

I tried to create client-server based web site including two page, webserver page is behaves as a server and webclient page as a client of this server..

I try to listen and accept to all clients wants to connect to the server when server page is loading.. but while it begun to listening for client pages, execution of server goes to slow then my server page couldn't open..

I also checked this codes in vb.net ad c# net ,it work correctly.

do you have any idea where can I download a good socket connection sample for asp.net?. I found code written for vb.net or c# desktop applications but I am not able to run this codes in asp.net..

Thank you in advance

im looking for something similar, have u had any luck?

hi aal27

i couldn't find anythin,g i thougth there is no chance to todo this...

send me a message if you find something useful

Wednesday, March 21, 2012

Need help with passing params to server

Hello,

I'm new in Ajax and perhaps you can help me. Here is a very simplified code of my application

default.aspx:

<

formid="form2"runat="server">

<

asp:ScriptManagerID="ScriptManager1"runat="server"/>

<

asp:UpdatePanelID="UpdatePanel1"runat="server"></asp:UpdatePanel>

<

asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>

<

asp:AutoCompleteExtenderID="AutoCompleteExtender1"runat="server"ServiceMethod="GetResult"ServicePath="WebService.asmx"TargetControlID="TextBox1"/>

</

form>

default.aspx.cs:

protected void Page_Load(object sender, EventArgs e)

{

for (int i = 0; i < 5; i++)

{

LinkButton lb = new LinkButton();

lb.ID = i.ToString();

lb.Text = i.ToString();

UpdatePanel1.ContentTemplateContainer.Controls.Add(lb);

base.CreateChildControls();

}

}

And in WebService.asmx I need a service for AutoCompleteExtender that will return result depending on what LinkButton was pressed.

As far as I understand, there is no direct way to pass additional params to server with AutoCompleteExtender.

But perhaps there are other ways?

For example, can creating of a new custom control or using Sessions help?

You can pass additional params as querystring to the server.

ex:

AutoComplete.asmx?KEY=2

To retrieve the value in webserver use

HttpContext

.Current.Request.Params["KEY"]

This option was working with ATLAS but now its not working with Ajax 1.0