Internet explorer 8 issues with design - c#

I'm working on a project a tool to track holidays and there are some parts of this application (report administration), the role "user" should not see. So far that works without problems, but somehow the representation of the parts that a "user" should not see look terrible:
The permission who should see something on the page is controlled in the Web.sitemap
<siteMapNode title="Vacation" roles="Administrator,Location Business Leader,Business Leader,Department Leader" description="All employees with vacation" url="~/EmployeeView/UserVacationGrid.aspx" />
If someone had the same problem and, could you give me some good tips or a solution how to fix this I would really appreciate it!

The problem is that whatever you are hiding (either client side or server side) is not encapsulating all of the controls associated. So for example, if you were using an ASP.NET menu, then you could hide a menu option server side with the following code:
switch (UserRole) {
case "Administrator":
Menu1.Items.Item(0).Enabled = false;
break;
}
These controls will make sure to collapse all the associated HTML with that option. If however you are using your own controls, or hiding things client side you need to make sure to hide the entire container (i.e. <div>) containing the control. A good way to do this is with jQuery:
$("#divVacationControl").hide();
Your best bet at figuring out which controls in IE8 are not being hidden and leaving that undesirable look is to use the IE developer toolbar. You can access it via F12 button, or Tools -> Developer Tools It can also be downloaded from here: http://www.microsoft.com/en-us/download/details.aspx?id=18359
Once open use the 'Select Element by Click' function to inspect the non-hidden elements and inspect the DOM. You can then find the culprit not being hidden and check your logic.
The last method if it only happen in a certain browser is to set its compatibility mode. Not saying this is the best way but it's an option. You can read how to do this in a blog post of mine below; just use IE7 or whatever worked for you. I would not recommend this approach as a long term solution unless this is a corporate intranet app that you have total control over the environment.
Specifying Document Compatibility Modes for ASP.NET Intranet Sites using IE8

Related

SPA (Single Page Application) Render client or server

I have a simple yet not so easy question. (So, I suppose)
I have a current DurandalJS application in production. I am generating my views using C# Razor syntax. So, I am still using my controller to pass the HTML to the client. Rather complicated to get setup using routes/areas/etc but it has been working.
I am using server side for only one real reason. (other then validation, but we can ignore that for now as I am sure model validation has improved and there are ways to handle this now)
Lets say I have a button. And I only want to show that button on the screen if the user is an admin. Now, of course I can use KnockoutJs (or Auelia/Angular/whatever) to find out the users roles and "hide" the button. But as far as I know, the button is still inside the HTML? (it is in Durandal, not sure if the newer libraries handle this different). So, currently I use server code to do the check then the HTML gets rendered without the button.
Knowing how many people use SPA type libraries, what are most of you doing for simple use cases like this?
Oh, yes, on the server for the return API call, we would have security anyway, so assuming someone activated the button it would not work anyway, I simply do not want my users ever seeing it.

Adding a re-usable 'box' to my asp.net web app

I'm building a basic web application in ASP.NET 4.0 with C# in Visual Studio 2010 Pro. I'm still very new to C#, and am used to Delphi coding. My website already has registration/login, and although I use some asp.net controls, a majority of my pages are dynamically loaded from my SQL database and I manually compile the HTML code from C# and insert it into the document.
Now what I would like to do is implement a poll - or a vote box - an 'object' which can be re-used in different pages. My website's master page already has a permanent left panel which has things which show on every page. One of these will be a small box with a vote of a few questions.
All I need to know is how do I begin to build an independent plugin control for a web page like this? I don't necessarily mean a separate DLL or anything, my existing one can handle everything. But I'd like to re-use the same little voting box in different pages too. So I'm assuming this will be considered a separate page, in a way, which is probably about 120 pixels wide by 80 high. Each vote will be limited to either login account or ip address (which I already have access to). So this solution must interact with the existing asp.net application.
So how do I begin the 'backbone' of such a plugin which can be re-used in multiple pages? I do not plan on distributing this plugin, and I don't even know if this is the correct term for what I need. Just a 'box' which can be 're-used' on multiple pages - which must interact with the asp.net app.
To better explain what I mean, imagine how Facebook has the plugin where you can embed some general info about likes and such. I'd like to make my own box like this - and even be able to embed it in other websites.
It sounds like you just need to make the poll into a user control. The documentation should get you started with them. A control can access everything an ASP.NET page can when it comes to the login information. It won't handle embedding into other pages though – embeddable active content that authenticates against your site is a nontrivial problem.
As I said in the comment, if most of your HTML is creates as a blob that's opaque to ASP.NET, it will probably be nontrivial to insert a user control into the middle of it.

C# WinForms: Should I use a web browser control

I am building a windows forms application that I will be adding a control within that will display quite a bit of different data. For the most part the data inside will be navigation buttons and help/training text.
I think it would be ideal if I could write the contents in HTML and then just display that in the control in the application, but I am not sure if this is a good idea.
Another point to note is there will be a web based version of the same application at some point in the near future, and doing this part of the application in HTML will make for very easy reusability.
The users will not have IIS installed, if this matters.
For this purpose, I think that an embedded web browser would be absolutely great. Alot of applications use a web browser control for navigation, information, training, etc. Steam is one example. In addition, reusability is almost always a best practice.
But I would use WebKit instead of the built-in IE web browser control.
I have a similar application and I think the WebBrowser control works very well. If you think it's what you need, I would for it and there's many other applications that do something similar. You can call Javascript functions in the HTML page from C# using HtmlDocument.InvokeScript(), and C# from Javascript using window.external and having this two-way communication makes life simple.
Users do not need IIS installed as you're not running a web server, just displaying content using HTML.
I would go for the built-in IE control rather than webkitdotnet to be honest. Although WebKit itself is superior to IE, the webkitdotnet project at version 0.5 it doesn't have the C#<> JavaScript communication or DOM access and it seems hard to tell if it's still being actively developed. It'll be great if/when it gets feature parity as IE is obviously far from perfect, but the advantage of the built-in IE control is every user of your app will have it already installed and the WebBrowser control is well tested. There are some disadvantages I've found:
IE versions may range from 6 to 9, so you'll to test to make sure your content works in all (as with a website).
There's a bug in IE (at least up to 8) that relative links do not work in combination with a <base href="file://...">. This can stop you being able to use relative links in your local HTML documents.
Sometimes pages display differently inside the WebBrowser control than they do out of it. For instance, http://bugs.jquery.com/ticket/7104 is one and I've come across another similar bug affecting cufon.
For compatibility reasons, even if your users install IE > 7 the WebBrowser control will still render your content in IE7 rendering mode by default. This is different to standalone IE which renders in the most-standard mode by default, so it can catch you out if you're not expecting it. You can change this by adding <meta http-equiv="X-UA-Compatible" tag if you want, though I actually found it makes life easier as it reduces the amount of different versions you've got to test against.

Prompting a user when activating a SharePoint feature through the site

I would like to know if there is a way to prompt the user when activating/deactivating a feature within SharePoint.
The background behind this is that I have a SharePoint solution that deploys several configuration files that are modified by the user when deployed to the site. I would like to either allow the user to decide whether or not to overwrite the files when activating or deactivating a feature.
Thanks guys!
Do you need this to work on ANY feature that is activated in your site, or just on features that are developed by you? If this is the latter case, you can add an event handler (SPFeatureReceiver) to your feature and catch the feature activated event.
EDIT: As per #Muhimbi's comment I finally understood the question - you want to allow user edit some properties and only then to activate the feature. In this case, I would suggest to define the feature as "hidden", so it does not show up in "web features" and "site features" list. Then create a custom page for "administration" of this feature, which would allow the user to override the settings in question etc. Then, register this administration page with SharePoint (again, deployed as a feature, these two features may be stapled together). Quote a good article about it can be found here: http://www.tonstegeman.com/Blog/Lists/Posts/Post.aspx?ID=13
EDIT2: found a similar article here on SO: SharePoint Feature Activation Form
One of the responses gives a good point - "The problem is, you don't always know where your feature activation code is going to run. If you turn on the feature using stsadm, it will execute in stsadm.exe, not the web process."

Tracking actions in a browser component

Im a c# developer and I believe that what I want to achieve is going to move out of the realms of some drop in .NET component so I am looking for advise on what I use externally which .NET can inter op with.
My requirements are to have an embedded web browser control in a WPF/Winforms applciation BUT I will also need to keep track of the following:
User interaction i.e. what pages they visit, forms submitted where they click etc.
DOM manipulation and traversing
I am guessing here but it seems that I might need to start looking at open source html/web browsers out there like WebKit etc. Is this the right track or is there anything currently available in the form of a control/COM object that I can use directly.
Cheers, Chris.
You should be able to accomplish point 1 using the webbrowser control in Visual Studio, but I dont think DOM manipulation is available, i do know you can traverse all the tags.
reference

Categories