AjaxControlToolkit HTMLEditor - Won't accept full stop keypress - asp.net

After utterly disbelieving our client when they claimed they couldn't type full stops (periods) into the HTML Editor control of the Ajax Control Toolkit on their ASP.net site, I've now sadly been forced to accept it is the case.
When you press the . key, and the cursor is at the final position in the editor nothing is added to the HTML Editor control at all.
If there are any characters after the cursor position, the . works normally.
If you hit return to enter a newline, and press . it works once.
This only only occurs in IE 11, older versions of it are fine, as are Chrome, Firefox and Safari. We are using the September 2013 release of Ajax Control Toolkit.
Has anyone else encountered this? Any advice would be much appreciated.

After doing more googling specifically around AjaxControlToolkit and IE11, I found a number of people complaining about problems with the current version of ACT (the Sept 2013 release) and IE11.
e.g. Here, here and here
It seems the problem is with .net failing to identify IE 11 as an IE browser, causing various AjaxControlToolkit features to fail.
The workaround I'm using at present is to add the X-UA-Compatible http header to our site, to force IE11 to process the page with in IE10 mode.
<meta http-equiv="X-UA-Compatible" content="IE=10">
There is also this .net4 hotfix from Microsoft which should fix the problem completely when applied to your web server.

Hope this helps someone else.
I found a similar problem with v3.0.30930 in Chrome, I tracked it down to the DesignPanelEventHandler. Specifically when conditionally dealing with deletions in various browsers when clicking the backspace button. In certain situations the code looks for a keycode of 46 or Sys.UI.Key.backspace, however in Chrome the full-stop keycode on keypress is also 46, causing all sorts of problems and finally meaning the event is stopped and the full-stop is never entered into the panel.
I overrode the DesignPanelEventHandler functionality and added the following condition in before the deletion logic and stopping the event (around about line 503 in HTMLEditor\DesignPanelEventHandler.js). As far as my tests go this seems to work fine:
if (key != String.fromCharCode(Sys.UI.Key.backspace).toLowerCase())
break;

Related

Using window.open equivalent in firefox causes ,NET session variables to go away. Why? How can I fix?

I have an application which runs in Adobe/Apache Flex with a .NET middle tier.
To run reports I need them to run in a separate window so I use;
navigateToURL(url, "_blank");
This works swimmingly in all browsers (IE, Chrome & Edge) except Firefox (FF). The app has been around for quite a while, and I can't imagine that it never worked in FF, but it doesn't with the last couple of releases.
The symptom is that the .NET "Current.Session.SessionID" changes to a new ID for both the original browser window as well as the new browser window. This causes it to lose all session variables, of course.
The problem only seems to manifest itself if I use "POST" to send variables to the popup window. If I use "GET" everything works fine. An added "bonus" is the "Post" parameters being sent to the new window disappear. So my report doesn't run, and the original window "loses its mind since the session ID changes."
As a test I dusted the cobwebs off and created two ASPX pages which did
<form method="post" name="TestForm" action="TestWopen2.aspx" target="_blank">
The problem was not exhibited in that environment on any browser including FF.
This leads me to believe that Adobe Flex (Flash) is mucking things up a bit.

DefaultButton and DefaultFocus in Internet Explorer 11

I have an ASP.NET page that contains an iframe. Inside that iframe, there is a form with a DefaultFocus and a DefaultButton set, as shown below.
<form id="Form1" method="post" runat="server" defaultfocus="txtSearchPhrase" defaultbutton="btnSearch">
When viewing this page in IE11, all of the content inside of the iframe appears to be shifted off the left side of the screen by about 100px or so. This does not happen in any other browser, including IE10.
If I remove the DefaultButton and DefaultFocus from the form, the problem disappears. I can then use Javascript to manually hookup the default button and focus, but since I have many different pages that are potentially rendered inside the iframe, it's not ideal to have to change each and every one of those pages.
Does anyone know what's causing this or if there's a better way to address it?
I looked into this and found some interesting things.
First, when you include DefaultFocus or DefaultButton on a form in ASP .NET WebForms, ASP .NET will automatically emit two things:
The definition of a WebForm_AutoFocus method.
A call to this method, which looks something like: WebForm_AutoFocus('defaultFocusElementID'); It does this for both DefaultFocus and DefaultButton settings, though I'm not sure why it needs to do this for the DefaultButton setting.
The WebForm_AutoFocus method attempts to call the scrollIntoView method on the element, but only if the browser is detected as a "non MS DOM" browser. Strangely enough, IE11 is not considered an MS DOM browser, at least as far as this method is concerned. So the scrollIntoView method is designed to run on browsers which are not IE.
I suppose one could argue the bug is with the implementation of the scrollIntoView method in IE11, but it could also be viewed as a bug in the MS JS library which detects whether the browser is an MS DOM browser. I'm not sure - either way, I blame Microsoft. :)
I recommend not using DefaultFocus and DefaultButton from a philosophical perspective because these are Microsoft-specific things, and when you can keep your code away from Microsoft-specific things, you usually should. Especially when using the "Microsoft way" is totally broken. Rather, try something like this (if you're using jQuery):
<form data-defaultfocus="search">
<asp:TextBox ID="search" />
</form>
<script type="text/javascript">
// jQuery on document ready
$(function() {
var form = $('form'),
defaultButtonID,
defaultFocusID;
if (form.data('defaultfocus')) {
defaultFocusID = form.data('defaultfocus');
$('#' + defaultFocusID).focus();
}
if (form.data('defaultbutton')) {
defaultButtonID = form.data('defaultbutton');
form.on('keypress', function(event) {
if (event.keyCode === 13) {
__doPostBack(defaultButtonID, '');
}
});
}
});
</script>
This is not tested code, but you get the idea. Then you can go through and use data-defaultbutton and data-defaultfocus on your form elements instead of the Microsofty way of doing it, and it will actually work, and if it doesn't, you can fix it, because you control the code!
I hope this helps.
Update
I found this Microsoft KB article which discusses a .NET 4 patch. Issue 2 on this page appears to address an issue which might be the one you described.
When you access an ASP.NET-based webpage by using Internet Explorer 11, the webpage renders the content incorrectly.
Note This issue occurs because Internet Explorer 11 is not recognized as Internet Explorer by ASP.NET.
I haven't tried it out yet, but it seems like this would fix it.

Postback page minimized the browser - Selenium WebDriver

I have a web page that have few dropdowns and when the dropdown item changed it refresh the page and reloads.
so now i am writing script against that page and i have noticed that whenever my scripts select the text from the dropdown my browser get minimized.
my questions, is there any setting to make sure my browser is maximized while running the script?
Here is the code that SelectText from the dropdown:
public void SelectText(By locator, string txt)
{
IWebElement element = driver.FindElement(locator);
SelectElement selectelement = new SelectElement(element);
selectelement.SelectByText(txt);
}
I am using
IE 8
Selenium 2 WebDriver
C#
I strongly suspect that the browser is actually being dropped to the bottom of the Z-order, not minimized. That is to say, it's being pushed to the bottom of the stack of open windows on your desktop. If you have other applications running, and they're running maximized, it can appear as though IE has been minimized, but it really isn't. There are certain actions that are known to cause IE to behave this way, but no one has been able to figure out why yet.
Maximizing the IE window won't solve the problem. Nevertheless, you can maximize the IE window using
// WARNING! Untested code written from memory
// without the benefit of an IDE. Not guaranteed
// to be syntactically correct.
driver.Manage().Window.Maximize();

Devexpress errors in IE

I have a complete ASP.NET that makes heavy usage of your DevExpress ASPx suite of controls. Grids, text boxes, round panels etc.
THe site works flawlessly in Chrome, Firefox however in IE some UI does not function. Example, i have an ASPxComboBox control. In IE it doesn't "Drop down".
Using F12 developer tools on the console line the following shows as the error code when the dropdown should fire
SCRIPT87: Invalid argument.
DXR.axd?r=1_42-DSzC3, line 1268 character
The function is below, line 1268 is line 5 in the code below
function _aspxCreateStyleSheetInDocument(doc) {
if(__aspxIE)
return doc.createStyleSheet();
else {
var styleSheet = doc.createElement("STYLE");
_aspxGetChildByTagName(doc, "HEAD", 0).appendChild(styleSheet);
return styleSheet.sheet;
}
}
Any suggestions where to start ?
Is resource merging enabled in web.config?
<devExpress>
...
<compression enableHtmlCompression="false" enableCallbackCompression="true"
enableResourceCompression="true" enableResourceMerging="true" />
...
</devExpress>
This issue is a specific of the IE browser (it can be encountered when too many stylesheet links are registered within a page). To resolve this issue, it is recommended that you enable “Resource Merging” http://help.devexpress.com/#AspNet/CustomDocument6911 option.
If AutoFormats/Themes are used, deploy controls skin via the «ASPxThemeDeployer” http://help.devexpress.com/#AspNet/CustomDocument7485 tool in the “Only skin files” mode.
See Also:
http://www.devexpress.com/kb=K18487

JS window.close() let IE hang

for reason I won't bore you with, I'm writing an asp.net application that must open some pages in new browser windows.
I managed to open them within a postback (don't ask why, I just needed to) with this code:
script = String.Format(#"window.open(""{0}"", ""{1}"");", url, target);
ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true);
Now I have new windows each one with a button that should close it. I have simply an onclick="window.close()" (but that prompts me when I'm closing the browser) or window.open('','_self','');window.close() (horrible, I agree but it's the only way I found to avoid the JS prompt)
On firefox it works perfectly but on IE7 (the browser our customers have) after 2-3 times I use that button to close the window I can't open other windows (in both cases, with or without the JS prompt). With the method above it does nothing, and with a click me a new window is opened but hangs on loading (it doesn't even calls the Page_Load).
What could be the cause? How can I solve this?
Thank you.
EDIT:
I forgot to mention that I'm using MS Ajax in most of the pages, and that may be the reason that forces me to use window.open('','_self',''); before window.close()
I don't know if this could cause also the hanging of IE
EDIT: Ignore that, it does still prompt the user - sorry!
For your first issue about closing the window, have you tried:
self.close();
Not too sure about the hanging issue though, I use window.open() and have never experienced issues in IE7.
I finally came to a solution:
on the attribute assignment there was a return false; missing.
Now it works perfectly with "window.open('','_self','');window.close();return false;".

Resources