Wednesday, March 28, 2012

update several textboxes from different services

I am trying to write my first application using atlas. what i want is to have 3 labels and one textbox. and one button.

the user enters a word into the textbox and clicks the button. what i then want to happen is for all 3 labels to be populated by calls to 3 separate webservices. sounds simple enough but..

these webservices may take some time to return, and i don't want to postback the entire page and then the user have to wait for each service to return before the page reloads.

What i want is for each label to be updated independently, so label1 migth be updated before 2 and 3
and 3 might be updated before 2. but at least the time the user has to wiat before something is returned is only as long as it takes for the first label to be updated.

i've read the following article on codeproject
http://www.codeproject.com/Ajax/HelloAtlas.asp

but this just deals with a partial postback to the same page, which isn't what i need to do.

If anyone can help or point me in the direction of an article that does something similar to what i would like to do, i'd appreciate it loads.

hello.

well, the scenario you describe can be easilly achieved by using the client portion of atlas. check this page:

http://atlas.asp.net/docs/atlas/doc/services/consuming.aspx#simple


Thanks for the reply. funnily enough i'd just started reading that tutorial.

I have made some progress. i enter a value in a texbox click a button. then 2 webservices are called asyncronously (ws1 sleeps for 5 seconds and returns a string ws sleeps for 2 seconds and returns a string) the results from these ws are then displayed in 2 textboxes.

However in order for the results to update these textboxes i've had to use standard html tags, not asp.net labels, i guess because they are generated server side.

What i would like to do is combine what i have so far with the display opf a progress animation like in this codeproject article.

http://www.codeproject.com/Ajax/HelloAtlas.asp

i think what i'm asking is how can i control an update panel and updateprogress cotnrol via javascript.

all i want it to be able to is whilst the webservice is being called, display a little .gif, and then when the webservice returns output the results within a dif

below is my code so far. any help would be appreciated

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"><Services><atlas:ServiceReferencePath="WebService.asmx"/><atlas:ServiceReferencePath="WebService2.asmx"/></Services></atlas:ScriptManager><div></div><inputid="inputName"/><inputid="buttonGo"type="button"value="GO"onclick="return OnbuttonGo_click()"/><atlas:UpdatePanelID="wsOne"runat="server"><ContentTemplate><inputid="Label1"type="text"/>

<inputid="Label2"type="text"/>

</ContentTemplate>

</atlas:UpdatePanel>function OnbuttonGo_click()

{

//Oh yes. method one gets called first but 2 returns first oh yes as ws one sleeps for 5 secs and ws2 only sleeps for 2.//now need to look at batching//and also need to look at how to update sections of the html page with the results.//can i use updatepanels?

requestSimpleService = WebService.testAsync(

document.getElementById(

'inputName').value,//params

OnCompleteOne,

//Complete event

OnTimeout

//Timeout event

);

//Call script proxy passing the input element data

requestSimpleService = WebService2.testAsync(

document.getElementById(

'inputName').value,//params

OnCompleteTwo,

//Complete event

OnTimeout

//Timeout event

);

returnfalse;

}

function OnCompleteOne(result)

{

document.getElementById(

'Label1').value = result;

}

function OnCompleteTwo(result)

{

document.getElementById(

'Label2').value = result;

}

function OnTimeout(result)

{

alert(

"Timed out");

}


Ok, made a bit more progress. i can now output my results to separate divs.

All i need to be able to do now is to display a .gif in each div until the function returns.

function OnCompleteOne(result)

{

document.getElementById(

'wsone').innerHTML = result;

}

function OnCompleteTwo(result)

{

document.getElementById(

'wstwo').innerHTML = result;

}

<atlas:UpdatePanelID="wsOnePanel"runat="server"><ContentTemplate><divid="wsone"></div><divid="wstwo"></div></ContentTemplate></atlas:UpdatePanel>


hello.

first, you don't need to use an updatepanel in this scenario. the updatepanel let's you refresh a portion of the page but it should only be used when you're transforming an aspx page into an atlas page. second, you can do what you want easilly: to do that, you just need to show the icon during the start method and hide it during the end method.


aha well i've got it working. basically after each webservice call i set the inner html of the divs to the animated gif.

Then on completion the oncomplete function is called, which overwrites the innerhtml with the result.

requestSimpleService = WebService.testAsync(

document.getElementById(

'inputName').value,//params

OnCompleteOne,

//Complete event

OnTimeoutOne

//Timeout event

);

//display .gif

document.getElementById(

'wsone').innerHTML ='<img src=blue_forward.gif />'//Call script proxy passing the input element data

requestSimpleService = WebService2.testAsync(

document.getElementById(

'inputName').value,//params

OnCompleteTwo,

//Complete event

OnTimeoutTwo

//Timeout event

);

//display .gif

document.getElementById(

'wstwo').innerHTML ='<img src=blue_forward.gif />'

Update textbox value

Dear friends,


I'm trying to update a textbox value by values that occour in a for each statement.
Ex.:

List<string> words = new List<string>();
words.Add("Test1<br>");
words.Add("Test2<br>");
words.Add("Test3<br>");
words.Add("Test4<br>");
words.Add("Test5<br>");

foreach (string s in words)
{
txtOcorrencias.Text += s;
System.Threading.Thread.Sleep(2000);
}

I want that each word appear for time, but when the function runs, all the words at the same time.

How I code this?

It's because you are doing this on the server. The server doesn't return the page to the browser every time it sleeps. It runs all of the code and then renders the page.

Have you considered doing this in javascript?


Yes, I try to use javascript but I used Thread to simulate other methods that the application have to execute on the server.


This is one way of doing it:http://encosia.com/2007/10/03/easy-incremental-status-updates-for-long-requests/


gt1329a

I'm using the code you recommend to me, It works 100%.

Thanks.

update the contents of the update panel

i have an update panel that fetches data from the database...what i want to achieve is that whenever the database is updated, the contents of the update panel will also update. pretty much like gmail.Big Smile but im not sure if this is possible with the update panel. thank you.

Yes. this is possible. You have to use timer control to periodically check the database for new records. integrate your update panel with timer control.

or else check the below link

http://www.asp.net/learn/videos/view.aspx?tabid=63&id=78

Please Don't forget to 'Mark as Answered' if your problem get solved.

Update the gridview by using AJAX.

Hi,

Can anyone help me regarding update data in the gridview by using AJAX. Once enter the values textboxes and saved into Database, then gridview has to update the new changes. I am using C#.

Pls help me to know about this.

Thank you.

Call the Update method of the UpdatePanel which contains the GridView programmatically after you save values to the database.

...// Save to database

UpdatePanel1.Update();

Thanks

Update to Beta 2.0 and can not run on Server

I have recently upgraded my Web Page to use the new AJAX 2.0 beta. I have also included the November CTP. This works fine on my local PC, but when I run it on my Server, it blows up.

I had initially included all of my DLL's in the Bin folder. After reading many of the posts, I decided to install the ASPAJAXExtSetup.msi and ASPAJAXCTP.msi onto my server. No joy.

I get the following error message:

Server Errorin'/EDCC_Test' Application.------------------------Index was outside the bounds of the array. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack tracefor more information about the error and where it originatedin the code. Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identifiedusing the exception stack trace below. Stack Trace: [IndexOutOfRangeException: Index was outside the bounds of the array.] EDCC.PageBase.curUser() +687 File_Home.Page_Load(Object sender, EventArgs e) +92 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061 ------------------------Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

I am not sure where to start debugging this code. As I stated above, it works fine on my machine, but not from the server.

Can someone help point me in the correct direction? Is there a way to "Debug" the page from the server side like from within Visual Studio? Maybe allowing me to "step" through the code? Is there a way to show a more verbose error message that will point me in a better direction?

Thanks,

Bryan

PS: Before I upgraded my site to the Beta 2.0, it was running fine. (Thank goodness I had the foresite to try to install it onto a "test" site before making it live.) Big Smile

hello.

well, it looks like you're passing an index too big for an array.

to see how to get more info about the error on an asp.net, take a look at the <customerrors> element.


Hello,

I agree with Luis. I mean i'm not completely sure that by upgrading you broke something. You probably have a dropdownlist or maybe an array that isn't getting data put into it. What does your code look like? What does the data access layer look like?

Not sure of any way to actually do debugging on the server like you can in the VS2005 IDE, unless you can recreate the environment on your local machine (Database, Web Application etc.)

VS2005 Team System Developer includes the ability to do unit tests. This allows for you to actually step through your code and make sure that all of the pieces are logical and you don't have issues that would show up until you actually loaded up the website onto the server and tested.

Good luck and happy thanksgiving.

JoeWeb


Thanks all for your replies.

I figured out my problem by republishing a million times with different "Response.Write" and "Response.End" statements until I found the error.

I am developing an Intranet site, and I rely on the Windows user name to authenticate. When I created a "test" web site on my server, I had the "Allow Anonymous Logins" box checked somewhere in the properties. Once I removed this, it worked flawlessly. Jeesh, newbie mistake.

Bryan

Update to the latest Control Toolkit

If I want to update to the latest AJAX Control Toolkit and install the ASP.NET Future, what are the steps that I need to take?

For installation of Ajax toolkit watch this video and documentation at

http://ajax.asp.net (last video as of todays posting)

For futures which is still in development

http://www.asp.net/downloads/futures/default.aspx, select quickstarts from there


I already know how to install AJAX toolkit. I just wanted to how to update to the latest version. Some of the question are: Do I need to delete anything? If yes, what? If not, will it automatically update the controls in my Toolbox?

As for the Future, I already watch the video there...but it was not helpful nor does it answer my question. My question was, and I will repeat again, if I don't already have a Dynamic Data Website, what do I need to modify or configure my site so that I can go ahead and use the Future components? Second of all, the video is not in C# so it is pretty much useless to me because I don't program in python.


Well if you do exact installation in same folder where you extracted your zip files and installation, then it will overwrite, I usually keep a copy of previous dll just in case. However I did a check two weeks ago and the old toolkit is exactly the same as new one.

As for futures is concerned, I would suggest you to wait, but the choice is yours? However play with it if you want. you can always convert python to c#, logic remains the same. Hope that helps pal


Thanks for the response. I'll keep that in mind.


Mark that as answer for other people looking for the same question or put a response and mark as an answer


Sorry. I thought I did. I have been having so much problem with the asp.net website lately. The page kept going blank or not loading at all.


Infact this forum page crashes everynow and then too..


So just to clarify for the hard of thinking, to install the latest toolkit on top of the previous one, all I have to do is:

download the latest version zip file


On your server, just replace the old AjaxControlToolkit.dll with the new one. That's it.

On your dev box, replace the old files with the new files, run the VSI, and update your Toolbox if you've added the Toolkit there. That should be it.

Update Trigger and GridView problem

Hi!

I have an Accordion on my page. In one AccordionPane, i have an UpdatePanel containing a GridView and a button under. When i try to access my gridview in the code-behind, i encounter a problem. The trigger of my button doesn't work, the method associated with my button isn't called. If i click a second time and the button, it postback my page and i lose all the data and the page. if i click a third time, the trigger associated with the button finally works.

I only get this problem when i try to access my GridView in my page.

I add my code and underlined the line which causes the problem, i remove it everythin works fine

aspx file:

<asp:UpdatePanelID="UpdatePanelGridStartSecurities"runat="server"UpdateMode="Conditional"ChildrenAsTriggers="false">

<ContentTemplate>

<divclass="ContentPaneDetails">

<%-- GridView : Supports de depart--%>

<divclass="ContentPaneElement">

<asp:GridViewID="GridViewGainOption_StartSecurities"runat="server"AutoGenerateColumns="false"BackColor="White"

BorderStyle="None">

<Columns>

<%-- Inclure --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="LbGainOption_Include">

Include

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:RadioButtonID="GainOption_Include"runat="server"BackColor="ActiveCaptionText"GroupName="IncludeExclude"

Checked='<%# ((bool)DataBinder.Eval(Container.DataItem, "IsExcluded"))?false:true %>'/>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"HorizontalAlign="Center"/>

</asp:TemplateField>

<%-- Exclure --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="LbGainOption_Exclude">

Exclude

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:RadioButtonID="GainOption_Exclude"runat="server"BackColor="ActiveCaptionText"GroupName="IncludeExclude"

Checked='<%# DataBinder.Eval(Container.DataItem, "IsExcluded") %>'/>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"HorizontalAlign="Center"/>

</asp:TemplateField>

<%-- Valeur mobilière --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="LbGainOption_SecurityName">

Valeur mobilière

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:TextBoxID="GainOption_SecurityName"runat="server"BorderStyle="None"Text='<%# GetSecurityName(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "SecurityId"))) %>'></asp:TextBox>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"/>

</asp:TemplateField>

<%-- Isin Code --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="GainOption_IsinCode">

Isin

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:TextBoxID="GainOption_IsinCode"runat="server"BorderStyle="None"Text='<%# GetIsinCode(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "SecurityId"))) %>'></asp:TextBox>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"/>

</asp:TemplateField>

<%-- Seuil --%>

<asp:TemplateField>

<HeaderTemplate>

<labelid="LbGainOption_Threshold">

Seuil %

</label>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:TextBoxID="GainOption_Threshold"runat="server"BorderStyle="None"Text='<%# DataBinder.Eval(Container.DataItem, "TriggerringThreshold") %>'></asp:TextBox>

</ItemTemplate>

<ItemStyleBorderColor="Black"BorderWidth="1px"/>

</asp:TemplateField>

<%-- Supprimer --%>

<asp:TemplateField>

<HeaderTemplate>

</HeaderTemplate>

<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>

<ItemTemplate>

<asp:LinkButtonID="GainOption_Delete"runat="server"CommandName="Delete">Supprimer</asp:LinkButton>

</ItemTemplate>

<ItemStyleBackColor="#D5DAE0"BorderStyle="None"/>

</asp:TemplateField>

</Columns>

</asp:GridView>

</div>

</div>

<divclass="ContentPaneDetails">

<divclass="ContentPaneElement">

<%-- Ajouter un nouveau support de départ --%>

<asp:LinkButtonID="GainOption_AddStartSecurity"runat="server"Text="Ajouter une valeur"OnClick="GainOption_AddStartSecurity_Click">

</asp:LinkButton>

<br/>

<%-- Nom du support --%>

<asp:LabelID="LbGainOption_StartSecurityName"runat="server"Visible="false"Text="Valeur moblière :"></asp:Label>

<asp:TextBoxID="GainOption_StartSecurityName"runat="server"Visible="false"></asp:TextBox>

<asp:ImageButtonID="ImgGainOption_StartSecurityName"runat="server"ImageUrl="~/Images/Directory.gif"Visible="false"/>

<ajaxToolkit:AutoCompleteExtenderID="AutoCompleteGainOption_StartSecurityName"runat="server"TargetControlID="GainOption_StartSecurityName"

ServicePath="WebServices/AutoComplete.asmx"ServiceMethod="GetSecuritiesListByLongName"CompletionSetCount="3"MinimumPrefixLength="3"

CompletionListCssClass="autocomplete_completionListElement"CompletionListItemCssClass="autocomplete_listItem"

CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"UseKeyValuePairs="true"

KeyHiddenFieldID="HiddenModify_SecurityId">

</ajaxToolkit:AutoCompleteExtender>

<%-- Isin du support --%>

<asp:LabelID="LbGainOption_StartIsinCode"runat="server"Visible="false"Text="Isin : "></asp:Label>

<asp:TextBoxID="GainOption_StartIsinCode"runat="server"Visible="false"></asp:TextBox>

<asp:ImageButtonID="ImgGainOption_StartIsinCode"runat="server"ImageUrl="~/Images/Directory.gif"Visible="false"/>

<ajaxToolkit:AutoCompleteExtenderID="AutoCompleteGainOption_StartIsinCode"runat="server"TargetControlID="GainOption_StartIsinCode"

ServicePath="WebServices/AutoComplete.asmx"ServiceMethod="GetSecuritiesListByIsinCode"CompletionSetCount="3"MinimumPrefixLength="3"

CompletionListCssClass="autocomplete_completionListElement"CompletionListItemCssClass="autocomplete_listItem"

CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"UseKeyValuePairs="true"

KeyHiddenFieldID="HiddenModify_SecurityId">

</ajaxToolkit:AutoCompleteExtender>

<%-- Seuil du support --%>

<asp:LabelID="LbGainOption_StartThreshold"runat="server"Visible="false"Text="Seuil : "></asp:Label>

<asp:TextBoxID="GainOption_StartThreshold"runat="server"Visible="false"></asp:TextBox>

<%-- Insert --%>

<asp:LinkButtonID="InsertGainOption_StartSecurity"runat="server"Visible="false"Text="Insert"OnClick="InsertFromSecurity_Click"></asp:LinkButton>

</div>

<divclass="Clear">

</div>

</div>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="GainOption_AddStartSecurity"EventName="Click"/>

<asp:AsyncPostBackTriggerControlID="InsertGainOption_StartSecurity"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

cs file:

protectedvoid Page_Load(object sender,EventArgs e)

{

if (IsPostBack ==false)

{

HiddenModify_NavigationMode.Value ="1";

//HiddenModify_NavigationMode.Value = "2";

//HiddenModify_MonitoringMandateId.Value = "7";

LogicMonitoringMandates monitorings =LogicMonitoringMandates.getInstance();

LogicGainMandateOptions gainOptions =LogicGainMandateOptions.getInstance();

LogicLossMandateOptions lossOptions =LogicLossMandateOptions.getInstance();

LogicSellMandateOptionDetails sellDetails =LogicSellMandateOptionDetails.getInstance();

LogicBuyMandateOptionDetails buyDetails =LogicBuyMandateOptionDetails.getInstance();

LogicPortfolios portfolios =LogicPortfolios.getInstance();

LogicSecurities securities =LogicSecurities.getInstance();

LogicPortfolioPositions positions =LogicPortfolioPositions.getInstance();

LogicPortfolioPositionDetails details =LogicPortfolioPositionDetails.getInstance();

securities.GetSecurities();

if (HiddenModify_NavigationMode.Value =="1")

{

/*

RadioButton gainOption_AutomaticPerimeter = (RadioButton)AccordionPaneGainOption.FindControl("GainOption_AutomaticPerimeter");

RadioButton gainOption_00007Threshold = (RadioButton)AccordionPaneGainOption.FindControl("GainOption_00007Threshold");

gainOption_AutomaticPerimeter.Checked = true;

gainOption_00007Threshold.Checked = true;

*/

}

if (HiddenModify_NavigationMode.Value =="2")

{

int l_intMonitoringMandateId =Convert.ToInt32(HiddenModify_MonitoringMandateId.Value);

monitorings.GetMonitoringMandateByMonitoringMandateId(l_intMonitoringMandateId);

gainOptions.GetMandateOptionsByMonitoringMandateId(l_intMonitoringMandateId);

HiddenModify_GainMandateOptionId.Value =Convert.ToString(gainOptions.GetMandateOptionFromIndex(0).MandateOptionId);

GridView gridViewGainOption_StartSecurities = (GridView)AccordionPaneGainOption.FindControl("GridViewGainOption_StartSecurities");

The problem comes if I add the line above

//sellDetails.GetMandateOptionDetailsByMandateOptionId(Convert.ToInt32(HiddenModify_GainMandateOptionId.Value));

//gridViewGainOption_StartSecurities.DataSource = sellDetails.TABLE;

//gridViewGainOption_StartSecurities.DataBind();

AccordionPaneSignaletique_DataBind();

AccordionPaneGainOption_DataBind();

}

}

}

Does anyone know what i can do? Can i add the trigger of the updatePanel in the code behind in the pageload method ?

Thanks in advance,

I've been looking for this problem for all my weekend and i found what was the problem!!!!!!!

The problem comes from the Accordion component, during the Page_Load, the Accordion and the child component doesn't exists, but in my case i didn't get any error of "not found controls".

I found a fix on this page :

http://couldbedone.blogspot.com/2007/07/what-wrong-with-accordion-control.html

Thanks a lot to this guy!

i just added Accordion.FindControl("nothing") on a Page_Init and it works great now!