ASP.NET - application behaving differently on client machine

Asked By Anjali agarwal on 08-May-12 06:10 PM

Hi All,

  I have a application that is running fine on windows 2008 server. I have a client machine with windows 7 on it.

My whole application runs fine on windows 2008 server, but some of the web pages doesn't function properly on the client machine. for e.g.


I have this piece of code in my application
<div>
                      <telerik:RadButton ID="rad_btn_apply_filter" runat="server" CssClass="cis_button"
                        Text="Apply Filter" OnClick="BtnApplyShipFilterClick" Width="80px" SplitButtonCssClass=""
                        SplitButtonPosition="Right" CausesValidation="false">
                      </telerik:RadButton>
                    </div>

and the code behind on this btton is
protected void BtnApplyShipFilterClick(object sender, EventArgs e)
{
  try
  {
    txtErr.Text = "This is line #1\r\n";
   
     
    txtErr.Text = "ships are loaded sucessfully\r\n";
    //txtErr.Text = "First line\r\nSecond line";
  }
  catch (Exception ex)
  {
    throw ex;
  }
}
I dont see "This is line #1" in my txtErr box. I get the update progress control that keeps spinning the wheel and it does not go away

below is my code for update progress control. may be I am doing somethig wrong with the update progress control.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UpdateProgress.ascx.cs"
  Inherits="User_Controls_GenericControls_UpdateProgress" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<script type="text/javascript">
var ModalProgress = '<%= ModalProgress.ClientID %>'; 
   Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginReq);
  
  
function beginReq(sender, args) {
  // shows the Popup
  debugger;
  $find(ModalProgress).show();
}
</script>
    
  
   <asp:Panel ID="panelUpdateProgress" runat="server" CssClass="updateProgress" style="display:none">
   
      <asp:UpdateProgress ID="UpdateProg1" DisplayAfter="0" runat="server">
        <ProgressTemplate>
          <div style="position: relative; top: 30%; text-align: center;">
            <img src="../Images/progress.gif" style="vertical-align: middle" alt="Processing" />
            Processing ...
          </div>
        </ProgressTemplate>
      </asp:UpdateProgress>
    </asp:Panel>
    <asp:ModalPopupExtender ID="ModalProgress" runat="server" TargetControlID="panelUpdateProgress"
      BackgroundCssClass="modalBackground" PopupControlID="panelUpdateProgress" />


any help will be greatly appreciated.

Sreekumar P replied to Anjali agarwal on 09-May-12 01:44 AM
Hi,

1. Can you check for any javascript errors in the ClientMachine (using debugger or IE Developer Tool bar). ?

2. Did u checked with any other browsers ?



Also I am sure that u cannot see  "This is line #1" in txtErr box,
since ur code is like that, see that u assigning "ships are loaded sucessfully\r\n" to textbox to get both u have to code like this.

txtErr.Text = "This is line #1\r\n";
txtErr.Text+= "ships are loaded sucessfully\r\n";


please mark helpful if it seems to be that
by,
Sreekumar P
Vikram Singh Saini replied to Anjali agarwal on 09-May-12 04:48 AM
Hello Anjali Agarwal,

I copy-paste your code with assumption for non-available code part. And I too found the very same problem of progress image displaying in ModalPopUpExtender infinitely.

Cause of Problem:

In your code under script tag you have declared the way of showing modal pop up. But you have not declared any way of closing it or hiding it. And by default the default functionality of the ModalPopupExtender is to  require a button click from the Panel to close it. So this is the cause.

Solution to Problem:

  1. Set TargetControlID of ModalPopupExtender to invisible HyperLink control. Why? Because if TargetControlID is set to button itself, then ModalPopup expects itself to be closed by some button control in it.
  2. Called onclientclick of button to show modalpopup.
  3. To hide it we declare that code part in button event handler. After completion of task we hide it there.
The full working code is attached as UpdateProgress.zip. Check it out and let us know if the problem still persists.
UpdateProgress.zip
[)ia6l0 iii replied to Anjali agarwal on 09-May-12 10:01 AM
This seems to be a web application developed in ASP.Net. I believe you are using IIS as your webserver to host this web application. 

First of all, note that, when you say the application works fine on windows server 2008 - you have to be specific. 
a) It could be the browser you may be referrring to and not the Operating system.
b) If you're dumping the entire application to be hosted in a webserver for the client as well - then IIS versions come into the scene. Otherwise, it is primarily the reason a) above. 

Now for the other observations. 
a)  You seem to have associated a button click event handler to the click event of the RadButton. It is good to be specific and rephrase the method names, so that for a third eye, it is easier to grasp things.
<telerik:RadButton ID="rad_btn_apply_filter" runat="server" CssClass="cis_button" Text="Apply Filter" OnClick="BtnApplyShipFilterClick" .../>
So I would suggest you to refactot the method name to something like "rad_btn_apply_filter_Click"

b) You seem to be writing text twice to the same textbox. Note that your first line of code, although executed, would never show up on the screen because of the second line.
txtErr.Text = "This is line #1\r\n"; 
txtErr.Text = "ships are loaded sucessfully\r\n"; 

If you intended to append two lines of text to the "txtErr" control, then use concat method of the string object
Like, 
string firstLine = "This is line #1\r\n"; 
string secondLine = "ships are loaded sucessfully\r\n"; 
txtErr.Text = string.concat(firstLine, secondLine);


c) Please use Environment.Newline instead of the carriage return characters /r/n. Below is a sample.
string firstLine = string.format("This is line #1{0}", Environment.NewLine); 
string secondLine = string.format("ships are loaded sucessfully{1}", Environment.NewLine)"; 
txtErr.Text = string.concat(firstLine, secondLine);


d) For errors on the spinning progress - If you keep seeing the spinning image, then there is an error. To debug the error, look at your server logs if you have enabled logging in your web application. If not, use http monitoring tools such as "Fiddler", or the network tab in the "Internet Explorer debugging tools". Examine the http response received, and you should have some information on the failure.

e) On Exception handling, do not throw the exception object. Just use throw. You would lose the stack trace otherwise.
catch (Exception ex) 

   throw ex; 
}

Should be rewritten as, 
catch (Exception ex) 

  //do whatever you want with the exception, and then just throw.
   throw; 
}

 
Hope this helps.






Anjali agarwal replied to [)ia6l0 iii on 09-May-12 05:11 PM
Thanks for all the replies, but the problem was I have this code on my page

ScriptManager ScriptManager1 = (ScriptManager) Master.FindControl("ScriptManager1");
    ScriptManager1.AsyncPostBackTimeout = 37000000;

This was causing all the delays.

Thanks for all the help though.
kalpana aparnathi replied to Anjali agarwal on 10-May-12 03:15 PM
hi,

For delay causing in your code place this namespace :

Sys
.Webforms.PageRequestManagerTimeoutException

Regards,