Client side/server side event race.

 Hi.  I've got a page that

1) Takes some text fields as input

2) Does some math calculations on the input (server side via a "calculate" button click)

3) Then opens a new window with some detailed information (client side, via a "view report" button click)

The server needs to "calculate" before the user can click "view report" so I start with "view report" disabled.  I've got input validation on the "calculate" click, and at the end, I enable the "view report" button.  Everything is working well with one exception: If a user were to enter data, click calculate, then change the input and click "view reports" it's possible they would mistake the results from the previous "calculate" click, which is based on the old input.

 I added to the text boxes an event that disables the button from their "TextChanged" event.  This works well, except when an input is changed, and then the "view report" button is clicked.

The button's onclientclick event (client side) executes before the TextBox's TextChanged event (server side), displaying the stale report.

I would like to be able to replace the server side "TextChanged" event for a client side solution, that way it will fire before the button's "onclientclick."

Any help would be appreciated.

9/25/2007 11:51:34 PM 24353 articles. 2 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 59
Get it on Google Play
Get it on Apple App Store

Why don't you make a function and add the textbox change event code in it. And in button Click event code call that function before setting the reports. So it will always perform the text change calculations before setting report.

I compete with myself to motivate me!!

Do not forget to mark posts, that help you, as "Answer".
9/26/2007 1:53:02 AM

I guess it depends on what you mean by "setting" the report.

If by setting, you mean creating, then that's what I'm currently doing.

When the "Calculate" button is clicked:
1) Input is validated.
2) Calculations are done.
3) The calculated data is put into a string (the report).
4) The report button is enabled.

This still leaves the possibility for modifying the input fields after the report is created, but before the report is shown.

If by setting, you mean writing the report to the browser window (displaying it to the screen), there are a couple of problems with that.
1) The report generation is server side.  Displaying the report is client side.  I don't know how to call a server side method calculate from a client side script.
2) If I did recalculate in this way I would (by my estimation) end up transmitting an extra 100k and holding 200-225k in server memory *per button click* until the .NET garbage collection decides it's good and ready to come and free up that abandoned memory.  If I could clear up my own memory immediately, I would do this without hesitation, but I can't and Server 2000 Web Edition has a maximum of two gigs of ram.  Two gigs of ram coupled with moderate to high traffic and uncertain memory usage keeps me awake at night.

In my opinion it's too expensive to recalculate like that.

9/26/2007 5:52:27 PM

I've tried adding these to the Page_Load event:

daysBox.Attributes["onchange"] = "javascript:document.getElementById(\"ctl00_MainPlaceHolder_viewReport\").enabled = false;";
daysBox.Attributes["onchange"] = "javascript:document.getElementById(\"" + viewReport.ClientID + "\").enabled = false;";
It doesn't work.  Any ideas why? (In c# the button name is viewReport, but I'm using a master page.  That's why I'm using ctl00_MainPlaceHolder_viewReport instead.)
9/26/2007 6:36:44 PM

The javascript onchange event does not fire until after focus has gone to another input element.  I think you are looking for "onkeyup".  Also, remove the "javascript:" becuase it is not needed.  And the most important of all, there is no enabled property in Javascript.  It's backwards, you need to use "disabled" and set it to true.

Hope this helps!  Please mark the helpful post(s) as Answer.

Josh Stodola ← Come check out my blog!
9/26/2007 7:06:15 PM

Thanks, making those changes, I'm getting the button to disable... but I'm thinking "onkeyup" might be a bit overzealous.  IT disables the button even if the user tabs through the fields without making any changes.

I don't really see any events that are better suited to this than "onchange"  It does end up firing right before the "onclientclick" event of the button, so I guess the "onchange" does what I want it to do.


Thanks for your help! Smile 

9/26/2007 7:15:35 PM

OK, no problem!  I was thinking you were looking for something like onkeyup but I didnt think about the tab issue.  As long as onchange does what you need it to then we're all good.  Glad you got your problem solved!

Best regards...

Josh Stodola ← Come check out my blog!
9/26/2007 7:20:50 PM

Similar Artilces:

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click ( and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

Help with client side events Vs. server side events
Hi, Can someone look as the following script and tell me why marking the check box doesn't generate a client side event eventhough there's: onclick="checkClick()"? marked.  Thanks in advance, Sivan <%@ Page Language="c#" %><HTML> <HEAD>  <meta name="vs_targetSchema" content=""> </HEAD> <body>  <SCRIPT language="c#" runat="Server">  void Page_Load(object s, EventArgs e) {  if (!Page.IsPostBack)  {   Label1.Text = Label...

Client Side events and Server side binding
I want to filter a dataset, server side and bind it to a select control. Problem is my filtering must be done based on the text written by the user in a text input. To get this text i'm using client side keyboard events. I tried to use client side binding and it works fine, but the problem is my dataset has more than 10000 rows, and so the performance is awful. Only thing i can do i think is to rebind the select control to a filtered dataset, improving performance. This is my code at the moment: In the aspx: static HtmlSelect _control = null; [WebMethod(EnableSession = true)] publi...

Client side and server side
We have a application, where we have some validation on the clientside using EnableClientSideValidation. If you don't have fullscreen you can't see some of the error-messages. What we want is to jump to the place on the page where the message is displayed. One problem is that the button is a serverbutton (runat="server"). How can we accomplish this on the clientside using the same button. I have tried to use "onClientClick" and a link something like this:   <A HREF=>form<...

client-side and server-side?
hi, can someone tells me how diff is client side and server side are these two? When I tried to do validation ... I would use Javascript ... which has something like: document.forms[0] ... I think that's client side. My understanding on server side is the "form" ... like u will have <form action=".." method=post> ..... </form> ... so it will send to server ... am I on the right track? Are there any other type of server side examples? Hi, ASP.NET itself is server side. Every piece of code processed is done on a server. What comes out of this is sent ...

Server-side or Client-side
In general, I'm wondering if there are any criteria to use when choosing between using a client side element or a server side element. For example, if I'm going to put an HTML table on a page, how do I decide whether or not to use a server control?  Should the server side always be chosen or if there is not explicit server side functionality required is it better to opt for a "normal" client side table? Obviously, if there is a need for server side control the question is answered, I'm looking more at more ambiguous situations. Thanks  This is from Micros...

Server Side or Client Side
Hi I'm a bit confused about this whole server side / client side thing. Are applets, embeded objects consider client side? If I have a form within my aspx page which connects to a database on the server side what is it considered? If I have some business logic written within a VB file when the client access the functions within that business logic (for example some kind of validation function) does the client browser actually downloads that VB file? Can someone suggest how to differentiate between client side and server side components within a based website?  Hi, i can&#...

What is Client Side and Server Side?
I am New of ASP.Net What we can and should do client side and Server Side? What uses? Please any one clear my doubt. Thanking YouEndendrum Priyamudan P m R Clientside is basically what a person can see and serverside is where actions get processed. that's kinda simply puyt but thats the deal, you code serverside, and the html and javascript it generates let's the users for example click a button, then serverside you have coded what should happen when a button gets clicked for example turn text red. Then the server sends a new page with red text to the client (clientside...

Stop execution of server side event from client side
Dear All  I have a text box and i wrote code on the server side event( On Text Change). So when i write something on the text box it goes to server and execute the server side code. Now i want to control this sever execution from client side. i mean i want to cancel this postback from client side under some conition. can anyone plz help me? Regards Sure if you let us know what you want to be done. here is an example <asp:textbox id="txtFile" OnTextChanged="javascript:RefreshPage();" Visible=true Width=500 Runat=server/> function RefreshPage() { &nb...

Call client side and server side events together.
I have one textbox on my aspx page.I want to validate amount in that textbox. If it exceeds 100 then the alert message should show that amount is bigger.And it should not go further. But if the amount is less than or equal to 100, then after checking the condition onclientside, it should to the server side TextChanged event.I have written a javascript function which is being called on "onchange" event of textbox and if the value is valid, then it should call serverside textchanged event of the same textbox.Please its urgent. Mark it as Answer if you find it Helpful.Shailen  ...

executing my own function @ server side for a client side event
hi all, I have a client side dropdownlist control with onchange event. I am calling form1.submit() method in onchange event. is it possible to catch that event at server side ???ThanksPrashanth.J Not if you call form1.submit(). Try replacing that with <%= ClientScript.GetPostBackEventReference(DropDownList1, string.Empty) %>; Then in the Page_Load handler server-side: private void Page_Load(object sender, System.EventArgs e){ if ( this.IsPostBack ) {  // Place any code that needs to be executed ONLY on a post-back here.  string eventTarget = (this.Req...

doing client-side action after server-side event ends
 I have a asp-button;I want it to perform a client-side action after completion of the sever-side action((like:calling a javascript function after the click event of the button ends); You can inject some javascript from the server side button click event so that when the page renders on the client side it will invoke the function or javascript fragment. You can use the method Page.RegisterStartupScript to inject javascript, or you can assign the javascript fragment to a literal control which would be interpreted when the page renders on client side.  Can u add some code snippe...

Server Side control invoking a Client Side event
I need to figure out how to get a server side control to process the "OnMouseOver" event. Since server side controls do not have the onmouseover event associated with them, how would you make for example, a DropDownList have a "OnMouseOver" event associate with it? The DropDownList must be server side. I guess the idea here is to set client-side events on the server-side control. Any help will be appreciated. You may try something like this: In server side code DDL1.Attributes.Add("onmouseover", "javascript:alert('Hi')") Th...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in ( required field, range validator and others) question is the required field validator is a server side control. So does that mean that it does a post back? it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

Web resources about - Client side/server side event race. -

MUD client - Wikipedia, the free encyclopedia
A MUD client is a computer application used to connect to a MUD , a type of multiplayer online game . Generally, a MUD client is a very basic ...

3Q Digital Offers Peek At 3Q Facebook Ad Performance By Its Largest Clients
With Facebook set to report its third-quarter earnings Wednesday , digital marketing agency 3Q Digital offered some insight on how the social ...

Gallop Labs hires former Facebook Client Partner as Director of Sales
Gallop Labs , a social marketing and analytics firm, announced that it has hired former Facebook Client Partner Andrew Peebles as the company’s ...

Sydney builder Bill Issa convicted of attacking clients who complained about his work
... to fix up rundown family homes and transform them into something flashy and new. "It will feel like a new home," he promised one client. "It ...

Client’s “Great Thanksgiving Listen” Campaign Featured on Google Homepage
We love when our clients are successful, and StoryCorps and their amazing Thanksgiving Listen campaign being featured on Google’s homepage certainly ...

In Search Of Client Portals: Rocket Matter
Technology columnist Sean Doherty continues his search for client portals in practice management software-as-a-service offerings, this time checking ...

Agencies Should Follow Clients' Lead on Diversity
A few weeks ago, PepsiCo's Brad Jakeman called out advertising agencies for not evolving with the times. Most important, he criticized them for ...

Dropbox is shutting down Mailbox, the popular email client
Dropbox acquired Mailbox, the extremely popular email client, way back in 2013, and unfortunately it's now time to say goodbye. That's right, ...

Guggenheim Securities' clients - Business Insider Deutschland
The 16-year-old firm has been an adviser on 5 massive transactions in what has been one of the busiest years for mergers and acquisitions on ...

Lawyer defends cop who shot teen 16 times, says client feared for life
The lawyer for the Chicago police officer who fatally shot 17-year-old Laquan McDonald defended his client Friday, saying the officer feared ...

Resources last updated: 12/8/2015 11:20:46 PM