I am facing an awkward problem. I am working on a .NET web site for which we are making a mobile version as well. The mobile version seems to be working fine when I am viewing it from the browser on my laptop, but when viewing it from a mobile device (in my case HTC running on Android), there is a problem on button clicks. The postbacks simply freeze the page and after some time "Web page not available" is displayed. Even for simple cancel buttons that only have Response.Redirect associated with them.
Has anyone witnessed similar situation? Any ideas on what can cause this? I am using .NET 3.5.
The postbacks work through inserted JavaScript (__doSubmit). Mobile devices have patchy support for JavaScript. Is it possible to look at the device capabilities for instance by hooking into a WURFL database and look at the device capabilities. I could well imagine that this would be a problem for lower end devices but I am a bit surprised about HTC Andriod devices. Also to help isolate the issue I would test with a normal submit button i.e. one without runat="server" and see what happens then
Also you could try subverting your button and putting in some custom javascript to submit i.e.
OnClientClick="formname.submit();"
This link has some similar problems but with autosubmitting drop down lists
It's also dimly possible that the swollen ViewState is causing issues with the page size on postback. Generally if/when I have been developing for mobile I would turn this off if possible. The resulting page will be larger (a lot larger) than it needs to be. If nothing else you would need to make every effort to keep the pages as small as possible (IMHO)
I'm assuming that you are locked into webforms development at this point -so you could look at ASP.Net mobile controls to see if they behave better - there is a form control in there. But I have never used them or ever seen them used. Some other posters may have had great success with them though? Perhaps?
Not helpful but when we developed for mobile we used MVC which is at least more transparent in these kind of situations
Related
I'm developing a C# WPF XAML-based Windows desktop application, and the UI is beautifully smooth and slick until I focus a textbox. Once focussed, the update rate of the whole UI is much lower. I'd estimate it all runs at the "full" (?) 60fps originally, dropping to more like 30fps after the text control gains focus. I've dug around all sorts of Microsoft documentation and advice on WPF performance, but nothing seems to mention the mere act of a control gaining focus being a problem. It's quite mystifying. I've tried to use the Windows Performance Toolkit to analyse the issue, but I'm getting nowhere. I've been able to do a klugey workaround in some scenarios with judicious use of Keyboard.ClearFocus() when clicking any other control, which returns the update rate to normal, but it's not great to have to do that.
This issue can be readily replicated - a brand new VS2015 WPF project, with a text box and a button will show the issue (add Keyboard.ClearFocus() to the button's click handler). This demonstrates it's nothing specific to my application code, it's a framework issue.
Does anyone have an idea why the described issue may be occurring, or how I may be able to resolve it?
Update: I've uploaded a sample project showing the issue, here: http://muuh.co.uk/SlowTextbox.zip
I am in the middle of creating a form that will work with Tablet PCs. But right now i need to see what are the best practices that one can have when creating them. When i am creating forms i am referring to the forms where a user fills in data presses next it is similar to a survey application.
Does anyone have any helpful links or even suggestions that will help me understand the best practices for tablet PCs?
Although this isn't directly C# related, I found it to be a fine example of how to do forms for Tablets in the manner you describe, where the user can hit the Next or Back button to navigate thru a form in a user-friendly environment: http://jqtouch.com/
I just started converting a site that was designed for Tablet users earlier today and managed to finish about a 20+ field form to the point where I'm ready to plug in the existing .NET form fields first thing on Monday. If I can, I'll post an example after it's ready to go
Just create a next form & On Button_Click require.FormName & Form1.Visible=false
So a next form will open with different options,etc and the fist form will hide so it will look like a different page.
I have a web application, in which browser's back button functionality should be customized. It's like, whenever we click on browser's back button, it should take us to landing page(Login page), It should display error message saying that 'session expired. Please login again'.
I have gone through so many posts and even in stack overflow also, i saw few posts. But nothing worked for me. The java script approach i am using as a temporary workaround.Basically this JavaScript never allow us to go back. instead it will keep us in same page.
JavaScript i have used <script>history.go(1)</script>
Please help me to customize the functionality of Browser's back button.
Any suggestions will be really helpful to me.
Short answer: You cannot
A little longer: You shouldn't even try.
But if you insist: A Thorough Examination of "Disabling the Back Button." (from 2000, but since it is ASP I guess still valid for you :)
Newer dot net: Restrict user go back to previous page after signout
Ignore the older browsers do not support location.replace - IE3.2 is not considered older any more but ancient.
For this - you would need a custom solution and disabling back button will not help...
Usually you should not try to change the behavior of back button. But since this is the requirement, I would suggest the following:
Approach 1:
This calls for creating a navigation framework where you know which is the current page in the flow... This is only possible if you a sequence in which the pages will be called (like a wizard)
Approach 2:
Specific to your case : You can use jquery/javascript to identify if the back button is clicked.. If it is then you can do an ajax call to server to kill the session and then redirect the user to login page.
You can programmatically manipulate browser history using something like this:
window.history.back();
window.history.forward();
window.history.go(2); etc.
In HTML5 ready modern browsers like Chrome you can also do more advanced things including completely overwriting back button functionality using history.pushState() and history.replaceState() methods.
(https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history)
You can also go dirty and use javascript + ajax calls to react specifically to back button events, but this will also not work on some browsers. What you ask is not a native part of a web, so no matter what you will decide to use in the end, it wont be very easy or widely supported.
I am making a multi-threaded [workers] application. Each thread should have it's own Non-GUI WebBrowser that Navigates to a web page and writes data to fields and click a button. I also need each WebBrowser to have it's own proxy. I tried the classic Windows.Forms.WebBrowser but I got stuck at the proxy part as it depends on IE global settings which won't work in my case. Any recommendations are welcome.
note: I tried doing it through HttpWebRequest/Response but it will never work as the data to be passed to the page contains a field called [ab_test_data] which gets its value from javascript code that calculate the value according to AB testing which I don't even fully understand. So a WebBrowser would be my best solution, unless someone can tell me how to convert that Javascript code that calculates ab_test_data to C# code. The algorithm used by the page I am trying to access is really sophisticated.
note2: ab_test_data value depends on Window.Event and Timestamp which can't be simulated on a httpWebRequest/Response.
note3: I tried Gecko, But it won't let me do anything to the webPage unless GeckoWebBrowser is drawn on the form (which I don't want).
Any solutions are welcome.
edit: If you know any WebBrowser that works like I want in any different language (Maybe Java) I would like to know.
Thanks in advance.
CefSharp: .Net binding for the Chromium Embedded Framework
use http://webkitdotnet.sourceforge.net/
As a question that may help, I wonder why browsers don't allow a proxy per (say) window/tab? I think a lot of it is because of lack of usefulness with respect to development time.
It may also be because the browsers [presumably] have centralized engines for things like web requests and caches, etc... Perhaps, allowing a proxy per window and/or tab would fundamentally alter the design of the modern browser and or have negative performance impacts. I don't really know. To illustrate the point further, consider things like Incognito mode and Private Browsing. In these cases, the browsers have, at least, conceptually made separate caches per windows...but I still bet an Incognito window and a standard window (in Chrome) use the same underlying web request engine.
Right now there are so many people who want a JavaScript and DOM parser and interpreter. Projects like the HtmlAgility Pack and Jint are helping, but there doesn't seem to be a unified and standard solution; at least not one with the simplicity of a web browser.
[rant below]...
Unfortunately, projects like Jint and HtmlAgility are worrisome. For one, they're not IE, Chrome, Safari or FireFox. You don't exactly know what you're getting yourself into. For instance, you know that in Chrome page xyz.com loads and renders perfectly. You can fire up FireFox and see that maybe something is not quite the same and so on with the other browsers. But, with these libraries you don't really know what if not everything is working right (there's no visual display to do a quick check). Plus, who knows what pace they're being developed at. Do they keep up with HTML5? Do they lag behind the major browsers? What about performance? Even more so, browsers already have things like caching and performance enhancements, which I doubt you'll get with individual libraries.
The best browser control would of course be something like:
IWebBrowser browser = new IE();
IWebBrowser browser = new Chrome();
IWebBrowser browser = new Safari();
IWebBrowser browser = new FireFox();
I think that is a dream, unfortunately. For one, what if you ever wanted to load plug-ins with these? What about user profiles, user logins, and so on? I think most of us just want the muscle of the browsers without these extras.
I really do hope that you find a good Chrome solution. I don't know what, if any, luck you'll have in the FireFox realm - maybe you can keep us updated? These solutions are evolving so quickly - I had never even heard of CefSharp or WebKit.NET before today and I looked for the same thing (Chrome and/or FireFox .NET browsers) several months ago for my own use. It would be great if a lot of people got together, made a standard interface and then each company built their embedded browser against the spec. Here's to wishing.
I want to create with Asp.net a browser inside a web page, so that I can process the click events of the user (for statistics analysis).
I kwnow how to do it with Winforms but I need a full online solution, so that:
The user open an standard browser and types in a start url.
In this url the menus and bars of the standard browser are hidden and
the user can see a "simulated browser", with standard buttons
(back, reload, ...).
From the Asp (c#) code behind this page I can start collecting click
data.
Thanks in advance, and keep the good work.
What you want to collect (a heat map of clicks essentially) is doable, but I don't think the way you want to go about it is very feasible.
Try this out.
I think that using this kind of solution with frames, etc. is much more feasible than embedding a browser (this amounts to writing a browser that can be served up by some kind of java/silverlight technology, not trivial).
Another idea would be that since, I assume, you have the permission of your users to track their clicks, write a greasemonkey (firefox plugin) based on the javascript in the link I provided above. You could then have all users use this plugin script combination to give you their clicks.
Web browsers are normally designed to prevent this kind of cross-site scripting vulnerability. This would only be feasible if you had the complete cooperation of all sites involved.
I don't think browsers will allow you to do this, for the simple reason that it opens up a whole bunch of security holes. If you think about it, an attack site designed like this would be able to follow people around the net tracking their actions, stealing passwords, etc. without them even knowing it was there.
This is not so simple for a web app.
Your options are:
Create a plugin (or Greasemonkey script) for your favorite browser to collect click data.
JavaScript that tracks the user's cursor position. Keep in mind that this won't be reliable if your users go to other sites from within your site thanks to the fact that JavaScript doesn't work well if scripts come from different origins.
You won't be able to make a "browser" control like you can on a desktop app because browsers intentionally don't allow web sites to be that powerful.
For the "browser in a browser" effect, you can use the tag. Remember, you'll only be able to track user actions in this iframe if the source is from the the same domain as the page it's included on.
Cross domain scripting is impossible by client-side. For obvios security reasons, you can't even read from a frame or iframe pointing to somewhere not from your own site.
Maybe the solution here is to to build something similar to the famous PHPProxy, or PHPBrowser, in this case a "ASP.NET Proxy". Its not that hard to build, you can Google for many exemples of those little codes.
While I doubt you can hide the original browsers toolbars etc, you could set up a single page that does this (it certainly wouldn't handle everything though).
This page would contain a the buttons and textbox required (to make up the inner browser UI) and a placeholder that would contain the page that the user requested. Of course the page contained in the placeholder will need to have all the links replaced so that they can be tracked (I would use linkbuttons). I'm not sure how well form submits would work.
Personally I'd use a proxy if I had control of the computer.