This one has been a stumper for me. Its very easy to duplicate though a rather obscure issue. It came about as I was doing some javascript work on a web page yet also make use of the validation controls that ASP.NET provides.
Some specifics up front: using a Vista-based development machine with the 3.5 framework and IIS 7. I also have a QA machine that is running windows server 2003, also with the 3.5 framework but running IIS 6.
Take a page with a simple TextBox, Validation Control, and button to submit them. For example:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Text is Required" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
Simple ASP.NET validation control code here ... The idea here is that client-side validation code is generated for the required field and a postback is not done unless the text box has a field. If the browser does not support client-side scripting, then ASP.NET will catch it on the server side using the Page.IsValid property.
When I run this from my Vista-based development machine, the client-side scripting code is generated for both IE and Firefox and works just fine.
When I run from the win2003-based QA machine, client side code for the validator controls is also generated for both browsers. The validation code for IE works fine ... but does Not work for Firefox. When the submit button is pressed (with an empty text box), the client-side code appears to be ignored and a postback performed. Now the validation error is caught server side - but I want to know why its not working client side in the first place.
The interesting quirk here is that if I take page source views under Firefox from the Development machine (the one that works) and the QA machine (the one that doesn't) and compare them - the client side validation code is dramatically different.
Ideas on what to change to get the client side validation code to work in Firefox with the QA machine?
UPDATE: Had a few comments asking to see the generated source. I've saved the Dev and QA source as .htm files and zipped them up. You can get them at http://www.optsolutions.com/testvalidation.zip
Check your web.config for xhtmlconformance and make sure it is not set to legacy.
http://aspadvice.com/blogs/rbirkby/archive/2006/11/01/Client_2D00_side-validation-in-Firefox.aspx
I am having the same issue with a similar setup. Differences in the browserCaps settings is the most promising possibility I have come across so far.
http://msdn.microsoft.com/en-us/library/sk9az15a(VS.80).aspx
Related
We have an ASP.net 3.5 WebForms application using VB.Net which has been running for many years. In this application there is a gridview select button that does not postback for some clients. This problem started occurring for some of our client when we moved the web application to IIS 7 on Windows Server 2008R2 from Windows Server 2003.
The select button is defined in the gridview with asp:CommandField ShowSelectButton="True"
which generates code as follows (copied from HTML source):
a href="javascript:__doPostBack('ctl00$bodyContentPlaceHolder$GridView1','Select$0')" style="color:#333333;">Select</a>
For some Win XP, Win 7 users who use IE (various releases), it does not postback when the user clicks the generated button. All users have been checked to ensure that javascript is enabled. For other Win XP, Win 7 users who use IE and other browsers, it works fine.
Much googling has turned up information about Javascript postback problems, but nothing seems to fit.
Other information: The whole gridview row is enabled for postback with this code in the GridView Rowdatabound event:
e.Row.Attributes.Add("onClick", "javascript:__doPostBack('" + Replace(GridView1.ClientID, "_", "$") + "','Select$" + e.Row.RowIndex.ToString + "')")
which generates this HTML:
<tr align="center" valign="top" onClick="javascript:__doPostBack('ctl00$bodyContentPlaceHolder$GridView1','Select$0')"
Note that the Javascript reads identically to the javascript which does not work, except that clicking elsewhere in the row DOES work for all users. This brings me to three possible issues:
Is there something about the SELECT button being in a link tag that makes it fail for some users?
Is there a user setting that might be different?
Is it something the Internet Provider is blocking?
1.Is there something about the SELECT button being in a link tag that makes it fail for some users?
It seems unlikely, since the page should be rendered the same way for all users (unless you're doing client detection that you didn't disclose).
2.Is there a user setting that might be different?
Maybe. Things that I would look for include:
Check the Compatibility View Settings to find different settings (try this during development, as well).
Check whether users have add-ons that could interfere (run iexplore.exe -extoff to run IE without add-ons)
Force IE to ignore the cached pages (I find the easiest way to do this with IE7 and up is to press F12 for the Developer bar, and choosing "Always Refresh from Server" on the Cache menu).
3.Is it something the Internet Provider is blocking?
I doubt this very strongly.
I have developed a web site and used update panel controls on all pages. The site was working fine and partial rendering was also working fine. But today update panel just stopped doing any post back. I don't know if this has anything to do with Performance Analysis, since I was experimenting with it yesterday.
I am using Asp.NET AJAX 3.5 framework, ToolkitScriptManager on all pages.
Things I tried doing.
1.) Reloaded Binary for AJAX Control Toolkit
2.) Tried to reload update panel
3.) Page methods within Update Panel seems to work. And Autocomplete Extender is working appropriately.
4.) I did backed up my code from few weeks back. It is working as expected. So I tried to copy web.config from my backup and checked it on latest code. Still not working.
Currently on any page whenever I select an item from a dropdownlist it is not doing a typical asynchronous postback and doesn't load other dependent dropdownlists.
Also update panel is not working on any of my pages. There seems to be an issue related to web.config but not sure though(I also added a new web config file but not working).
Any help in related to this would be appreciated.
Thank You.
I have solved this problem. Cause: I have written "Response.write()" in my master page. I was able to track in Chrome Console window and this was error: Uncaught Sys.WebForms.PageRequestManagerParserErrorException: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. I removed response.write and it works as it was supposed to be.
Same thing as #Mitul but it was a Response.Redirect().
It works on localhost but not in production.
I added and works everywhere !
<asp:UpdatePanel runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="lnkAddProduct" />
</Triggers>
The "lnkAddProduct" is a LinkButton in a Panel.
Have some problems with client side validation (using RequiredFieldValidator, RegularExpressionValidator, CustomValidator with client side validation logic). It seems that WebForm_DoPostBackWithOptions is not fired or causes unhandled exception that makes the form to do the postback regardless it's valid or not.
I tried using a ValidationSummary, hiding it if javascript is supported:
<script>
$(document).ready(function() {
$("#javascriptDisabled").hide();
}
</script>
...
<div id="javascriptDisabled">
<asp:ValidationSummary runat="server" ...>
</div>
...
<asp:Button runat="server" OnClick="SendMessage" ...>
My .cs code is:
protected void SendMessage(object sender, EventArgs e)
{
if(!Page.IsValid) return;
}
Every thing works fine on Chrome with disabled javascript on my laptop, but not on my Android phone. The problem is that on the phone Javascript is not disabled, it's enabled, and correctly hides the ValidationSummary, but does not perform client side validation for some reason that i can't understand (no developers tools on Android browser :(( ).
This is very frustrating! :(
Someone can help?
Thanks!
EDIT: I found the cause (but not the solution, if one exists). I'm using in my page a Telerik RadEditor control that, if the client is Android default browser, does not correctly render all the embedded scripts that are required, causing javascript exceptions and (probably) the disactivation of javascript runtime by the browser. This causes the client side validation not working anymore. Will investigate with Telerik if there is a solution to this issue.
Try with fiddler. When I tryied, I must setup the emulator to work via fiddler proxy. Doing that in my app (I'm also putting data on a .NET authenticated WS), it worked.
Saludos, OSCAR.
EDIT: I found the cause (but not the solution, if one exists). I'm using in my page a Telerik RadEditor control that, if the client is Android default browser, does not correctly render all the embedded scripts that are required, causing javascript exceptions and (probably) the disactivation of javascript runtime by the browser. This causes the client side validation not working anymore. Will investigate with Telerik if there is a solution to this issue.
When running my application lately, there is a very long delay after a request is made to the server. When debugging and stepping through, the code finishes quickly and then a dialog comes up, which I'm assuming is the reason for the lag. (I've tried a series of other options including disabling usage of ViewState, disabling debugging, installing IE 8 and reinstalling the Ajax Control Toolkit.
The dialog reads as follows:
Find Source: ExtenderControlBase.cs
Original Location: C:\Users\swalther\Projects\AspNetAjax\Releases\30930\AjaxControlToolkitSource\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs
This is strange, since I am not familiar with any user on this machine named swalther (it was reformatted rather recently) and searching my computer for this folder turns up no results.
As usual, any help would be greatly appreciated.
That reference to swalther refers to the developer who compiled the code in the first place.
Fixed. (Second time I've answered my own question - go figure. I'm creating a database of my bugs :) )
Changed this line:
<asp:ScriptManager ID="scriptManager1" runat="server" EnablePageMethods="true" />
to this:
<ajaxControlToolkit:ToolkitScriptManager ID="scriptManager1" runat="server" />
Looks like you have to use the ajax control toolkit script manager instead of the ASP version.
I develop a web application which uses a lot of JavaScript. I developed first portion of code on my machine and everything works just fine. Problems occurred after deploying to remote machine to IIS - the page runs but i.e. whole validation that I wrote doesn't run - I've checked under FF, IE6, IE7.. Are there any IIS properties to set to make it run?
EDIT
I've just found out that the problem is here:
<script type="text/javascript">
function validate() {
return validateTrees();
}
</script>
The validate() function is called here:
<asp:Button ID="btnSubmit" CssClass="button" runat="server" OnClientClick="return validate();" Text="Send for approval" />
And validateTrees() function is loaded dynamically from .js file by the control:
<cust:CustomTreeControl ID="CustomTreeControl 1" runat="server" />
which is placed just before this submit button. It seems that after deploy the browser can't find validateTrees() function.
IIS shouldn't affect your JS in anyway (as long as the JS files are present and accessed properly).
Could you post some code examples of what you have (simple test cases, preferably) and what you expect it to do and what it isn't doing, and what, if any, errors you are getting.
IIS has nothing to do with this.
Your javascript files are downloaded by the browser on the client machine and runs there, not on the server.
Make sure you published your files correct.
Javascript typically runs on the client not the server. What makes you think this has anything to do with IIS?
Use a tool such as fiddler to confirm the browser is receiving all the content your expect.
Ok, that was silly, I didn't update paths to scripts after deployment.