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.
Related
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 am trying to run a simple ASP.Net Web Application/Site on Vista Box. Unable to run any JavaScript when I hit F5. However when I deploy the same to local IIS and call the application using IE8 this application works and the JavaScript executes.
Another observation, when I copy the URL (example: http://localhost:XXXXX/yyy/Default.aspx) to a new tab within the same instance of IE8, this same happens. JavaScript do not run.
But when I browse the same application using another instance of IE8 the application runs well, meaning JavaScript executes properly. where do I set it or override it. Please help
I am suspecting that its something to do with the Instance of VS2008 running on vista home premium, so in all the above failure cases I was running VS2008 as an Administrator.
Please help and let me know how to resolve this. Thanks in advance.
Had the same problem. Settings in IE9 had been modified.
Tools ==> Internet Options ==> Security Tab ==> Intranet icon ==> Custom Level Button ==> almost all the way down to the bottom, Scripting ==> Scritpting of Java Applets ==> Enable radio button.
In my case, it had been switched to Prompt. Stopped Cassini from executing Javascript.
And thank you to Mr. Matthew Ward for pointing it out to me! Almost all of the options are locked out for us, so I have no idea how this changed.
Odd thing is, running against the IIS server on my box, the javascript worked.
Couiple thoughts
1) your instance of IE8 might have JS turned off
2) path issues (as suggested by Jared)
3) the "local path" issue; some browsers block Js that appears to be running from disk (might be a setting in your IE 8 to fix.
My blind guess would be that there is some problem with the path to your javascript files. If you could post the .aspx file that has the javascript that isn't running it would help a lot.
UPDATE: Thanks for the comment with the html, you should consider adding it to your question.
This problem sounds like a timing related issue to me (and your html doesn't seem to have any issues) so here is what I think will help:
1) Move the following code to the bottom of the page.
<script type="text/javascript">
$(function() {
$("#accordion").accordion({ collapsible: true });
});
</script>
2) Don't use relative URLs for your script/css tags. So your <script> tags should look like:
<script src="/Scripts/jQuery/jquery-1.3.2.js" type="text/javascript"></script>
<script src="/ui/ui.core.js" type="text/javascript"></script>
<script src="/ui/ui.accordion.js" type="text/javascript"></script>
3) consider using a minified version of Jquery and the other script files to reduce load times for them. Also, you might want to consider using a CDN hosted version of Jquery (from google, or microsoft).
If none of these suggestions work I would suggest posting the HTML for the entire page into your question.
Locally it works, I know its the "it works on my machine" syndrome but i cant see why.
Simple web page, fields, required field validators, such as
<asp:textbox id="tbEmail" runat="server" CssClass="field"></asp:textbox> <asp:requiredfieldvalidator id="Requiredfieldvalidator2" runat="server" Display="Dynamic" ControlToValidate="tbEmail" ErrorMessage="Email is required" CssClass="required"></asp:requiredfieldvalidator>
button with
<asp:button id="btnSendRequest" runat="server" Text="Submit" CausesValidation="True"></asp:button>
Locally it triggers and the code doesnt run, on the deployed version the validators dont fire and the code runs.
Should be simple but ive been staring at it for too long.
Thanks people - Tariq
I was thinking the same thing - the asp_regiis will create the aspnet_client folder in the root of your site. Also watch for javascript errors being reported, they will help in the diagnosis.
I'm not sure if this is relevant for your version of .NET but you might have to run aspnet_regiis -i on the server to install the scripts for validation. Double-check this, please, before doing anything :)
I hope this sends you in the right direction.
http://msdn.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx
In a situation like this, I find it helpful to compare the raw HTML output you get locally with the output on the deployed server. You are probably missing the validation javascript on the deployed version, as Eric pointed out... but this will tell you for sure.
The difference might be that on your local test you are getting the client side validators triggered and on the server only the server side.
Make sure you add an IsValid if to your method, like:
void MyClickHandler(object sender, EventArgs e)
{
if( IsValid)
{
//rest of the code
}
}
Install Fiddler: Fiddler and watch the traffic. Is it getting any 404 or 500 HTTP errors while loading your page? It's probably trying to load the necessary client-side validation files but running into problems.
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