Cross-platform development - c#

I was just about to upload my new, redesigned website when I realised "crap, it's just like every other website."
Then I had an idea. And I've spent the past 2 weeks planning. I have but one thing left to do, and it's proving a little difficult to figure out how I can have my website for PC's, and a whole different site for an iPad (or just larger touch based computers in general) and another for Touch-based phones, and then one for regular phones with web browsing capabilities.
Is this possible? I want separation. I don't want a bunch of javascript files with commands for everything inside them. I want to separate each 'website' and serve it based on the platform requesting the document. How can we achieve this?
If you are to recommend any libraries that may help, note that I will not use jQuery (but list jQuery anyway as others who face this problem might not mind using jQuery)

You can use Asp.net MVC and switch your views depending on the device.
This way you can reuse all your controllers and have different views for each device you want.
Scott Hanselman wrote an article a while ago about this kind of development:
http://www.hanselman.com/blog/MakingASwitchableDesktopAndMobileSiteWithASPNETMVC4AndJQueryMobile.aspx
I would recommend jQuery Mobile to use in mobile devices. I also recommend Kendo UI Mobile, it really looks amazing but the mobile version is not free..
I also suggest to take a look at SPA (Single Page Applications). With SPA you could have a rich javascript application ready for any device. Combining it with Asp.Net WebApi looks very promising.
Jonh Papa made a course on Pluralsight that is completely worth it:
http://www.johnpapa.net/building-single-page-apps-with-knockout-jquery-and-web-api-ndash-the-story-begins/
It's all about thinking about what you really need and how much effort you can put in.

long answer short, i think what you are looking for is Request.Browser to do redirects. You can Access things like Browser.Browser or Browser.Version, i think even a IsMobileDevice is to be found there.
check out: http://msdn.microsoft.com/de-de/library/system.web.httprequest.browser.aspx

Related

Generating an Organogram in MVC and Displaying in View

I imagine this question will not bear anything, but this is a last ditch attempt before I have to tell my PM I simply can't do it.
My colleague (usefully before leaving the project) was a yes man to everything our PM asked for, regardless of what it was, and I seem to have been volunteered to create some functionality that will generate an Organogram / Organisational Chart and present it in the view.
I have dug around and asked around, no one really seems to know how I would go about doing this. Can anyone offer any advice on anything that can help? Even if it's the most basic tutorial or obscure API ever, it will be helpful.
To put a point on it, my question is: Is it possible to generate a chart in an ASP.NET MVC C# Application, and display it on a View? (Even a yes or no would help)
Yes, everything is possible. It's just a matter of how much time you can spend on it. Not everything has a good return on investment though, but that's for your PM to decide. As long as your team can make an estimation of the complexity.
But for ASP.NET, Microsoft has a Charting library that allows you to build charts. There are also commercial libraries (the first google hit) out there that are more feature rich.
And if they don't work, you can Always build images manually using the System.Drawing namespace of .NET (that will of course take considerably more time than plotting a chart using one of the available libraries). Generated images can be sent through an ashx handler, or you can embed the image in the same page using base64 encoding.
It's not bad to say yes to your PM, but I rather say: "Yes, we will stick this feature on the feature list / back log, and make a estimate of the complexity. Once we know the complexity you can choose to select it for a future iteration." But perhaps I'm talking too Agile now ;-)
You can hand off the chart drawing to an external library, for example, Google Visualization: Organizational Chart
Have a look at this question for other suggested librairies:
What's the best library to draw organization chart using JavaScript?
This sounds like it's in a commercial scenario, so it's really worth looking at the commercially available solutions. Steven already mentioned one, but as far as I can see that one is for Windows Forms and the other one is for charts as in bar charts and provides no organigram features.
A Javascript diagramming library with the capabilities of displaying organizational charts is yFiles for HTML. It has a nice online example of an organization chart that might be exactly what you are looking for:
There is also a Video that shows the demo in action.
The library is a pure Javascript implementation that does not depend on server libraries or servers at all. Integrating it in an ASP.net environment should be easy though, as long as you know Javascript. Being a library it offers full customization capabilities. You can determine the look and the feel of all aspects of the chart. Under the hood the library is a generic graph drawing and editing tool and the organizational chart is just one possible use-case.
Full disclosure: I work for the company that created the library, but on SO I do not represent my employer. My comments, thoughts, etc. are my own.

C# and ASP.Net. Guidance required

I am a student and do my work and projects in c#.. I have not experienced WEB still. The question I wish to ask is that whenever in or near future if I wish to switch onto developing WEB Applications on ASP.Net, will I experience any difference ?? excluding any syntax changes.. I mean in C# the way do Add Update and Delete Records and the calculations, will I be experiencing the same in ASP.Net??
I don't have any concepts of WEB.I want to ask you people that what do you consider the most important to learn before switching onto ASP.Net?
Guide me please.. :/
There are no differences in server-side code.
The main different is in the UI.
While Microsoft tries to maintain a UI experience similar to Windows applications using its custom controls and the designer, you need a good knowledge in HTML and CSS if you want to create complex UI tasks.
Custom controls actually generate client side code such as HTML, CSS and Javascript.
So your main challenge will be the presentation layer and how to create client side code that is well parsed on different browsers. It's more difficult than Windows' "Drag and drop" technique, but it's quite a lot more powerful.
You'll notice that you can't drag and move controls the way you do with Windows apps, changing their coordinates on the screen.
HTML is not about coordinates, it's based on a certain document flow in manually defined layouts.
Don't be tempted by changing Web controls to absolute positioning, just because you think it's "easier". It's a mistake a lot of migrators to ASP.NET do, and it's generally a huge mistake that I suggest you don't fall into.
If you are talking about the difference between Windows apps and Web apps, the most important and hardest thing will be for you to grasp the page life cycle. Check here for Microsofts overview.
I guess the web and desktop applications have considerable difference. The one and most important is that when on Web there are two states of WEB application
On Server side : where we have C# code and stuff.
Client side : Where we have CSS, HTML and JavaScript doing it all for us.
Besides this HTTP which is communication bridge.
This is one big different that desktop application developer face when they switch to the Web Applications.
I will suggest you to take a look at basics of CSS, HTML and JavaScript while swiching on web applications. That really helps in log term.
First, I'd say if you look into web application, make a few quick examles with ASP.NET WebForms, and then a few with ASP.NET MVC, to learn the differences between good design (MVC with AJAX and without postbacks) and bad design (quick and dirty WebForms with postbacks and without AJAX).
Try using JavaScript on pages, and look at how postbacks reset all JS variables, and the impact that has on anything dynamic. Also look at how postbacks exponentially increase the complexity (and bugs, such as session timeouts with label text stored in session) and decrease the debugability of your application.
Take a look at JQuery, JQuery uploadify and JQuery Treeview, and JQuery DataTable, and JQuery Charts.
Add and UpdateRecords imply editing a DataTable and saving the changes.
This is the worst thing you can possibly get your hands in with ASP.NET, that is, if you want to do it properly (with the possible exception of asynchronous data processing).
If you are really passionate to dive into web application development especially ASP.NET, I would recommend the following path for a beginner to kick start with.
Start learning HTML, JavaScript, CSS
Next you could try Classical ASP. Having a know how of classical ASP will definitely be a plus, when moving to ASP.NET because, you will under stand how ASP.NET renders pages and what ASP.NET controls really does etc etc. In my own words ASP.NET is a chocolate coated version of classical ASP, I am telling this from my classical ASP experience.
Next you need to firm understanding of on how the web works and its internals. If you need you could also refresh on How Internet works and How website works (this too).
Finally you could start off with ASP.NET 2.0 and later move to advanved stuff like AJAX, MVC etc.
You could further enhance you skill by learning jQuery and some CMS (Content Management Tools) like DotnetNuke.

Can I use silverlight to replace javascript and JQuery?

I have a webapplication that heavily uses JQuery. I would like to start using silverlight in its place if its possible. Instead of using jquery ajax features and other jquery features I would like to use silverlight. is this possible to do with silverlight?
Different tools. jQuery is best for manipulating the DOM. Silverlight is (ostensibly) best for rich internet apps, not manipulating the DOM. If your web application tries to create a cool UI using JavaScript, Silverlight might be a good fit to replace tons of JavaScript code.
If you application uses JQuery now replacing it with Silverlight will most likely not only entail redoing your JQuery features but also any HTML, CSS, forms processing and really everything about your application depending on what it does and how it is current designed.
I agree with Jonathon, they are really are two different tools.
Thanks.
Nick
nickgs.com
Technically, Yes.
But you must understand that you will have to rewrite all your application from the bottom. Microsoft propose the RIA Services as the best practice design to use with Silverlight but with this will make you change all your design and even the Data layer.
So the answer is Yes. But you would better stick with jQuery.
#Luke101, you can design an whole website using Silverlight no probs. The question though is what is your target audience?
Silverlight doesn't come shipped with the browsers as yet so a lot of computers don't have it yet and so need to download it.
Given the amount of paranoia out there I think people are a little hesitant to download something when a broswer asks you to.
The environment you'll be working in i don't think will be HTML any longer and you'll be working in xaml.
Also consider your target browser. There are still a lot of people using <gasp> IE6 and i'm not sure if SL will run on it.
What is the motivation behind moving to SL? If it's because it looks cool, don't forget a lot of that comes down to design and if you're not a design person you're likely to make a bigger hash of it than if you were working in HTML.
You may also want to look at how you integrate with a designer. I know MS Expression is designed to make the job easier but it's still an early product. Also, does your designer know about Expression or Blend and know how to use it?
What I'm getting at is there is a large learning curve here which equates to someones money and you may not see anything for some time.
Yes.
Silverlight runs in the browser, jQuery (JavaScript) also runs in the browser. So they can technically replace each other, assuming all the functionality you want in one exists in the other (including support in various browsers).
Yes. Silverlight with RIA services can replace a jQuery AJAX site. Depending on the site's features, you may even be able to break up the features of the site into silverlight "widgets" for individual functionality. The danger is that Silverlight can quickly balloon into an application that is difficult to update (though it will guarantee cross browser compatibility). Silveright is entering version 4 and it's still not finished yet, so it's changing rapidly.

Browser App - RAD UI Development - Is it possible?

I've been away from building browser applications for a long time. I'm now interested in creating one for a hobby of mine. I dread having to deal with HTML, JavaScript etc. to build a high quality browser based user interface. I've got the full suite of Telerik controls. Is it possible to build a polished, somewhat feature rich browser UI while being sheltered from the archaic environment of HTML and JavaScript? I'd love to be able to simply drag-drop components, much like building a Win UI and have the exact HTML, JavaScript code created for me.
Thanks!
Since you have the telerik controls suite, I suggest you have a look at the control demos or the sample applications, to see what's possible without having to program a lot.
In my experience, you can achieve a lot without having to program javascript or HTML (when using the telerik controls). But as soon as your application gets bigger and more complex, you will want to take care of things such as ViewState optimizations or taking advantage of the client-side programming APIs of the telerik controls to optimize your app (e.g. to get a more AJAXy kind of user-experience).
My sentiments exactly, so I now fully recommend to build Web apps with Silverlight (or Flash, but I am .NET guy, so my first thought goes to SL). Using HTML/Javascript is too much work.
SO is a fantastic Web app but I cannot imagine the number of hours spent to achieve this result, especially compared to a "real" programming environment.
MVC + JQuery + Telerik will allow you to be sheltered from a very large amount of the nasty HTML/JavaScript stuff. Silverlight is an option but you'll lose very large potential audience segments that may or may not be important to you (mobile web users, for example).
As somebody else mentioned, the Telerik demos pages are your friend - use them a LOT and you can avoid much of the HTML nastiness.

Building your own web controls

Well it's kind of a newbie question but I think lots of people have problems with this.
I'm developing Windows/web application for fun, and installing them at friends' places. Most of my developing concentrates on the CRM system, but I have a big problem with showing data from DB in better, more effective and lighter ways.
Using Microsoft built-in web controls is a nice and easy way, but it doesn't answer my needs, and worse, it's not that effective as other web controls in great software and websites(Google(lol)).
I want to build my own controls(GridView, etc...). So my question is how can I do this myself?
How does Microsoft build their web controls for both web and Windows Form developing?
Thanks!
Amit
Here's the starting place for learning about creating your own web controls.
http://msdn.microsoft.com/en-us/library/bb386565.aspx
And here's an older reference, but probably a better place to start.
http://msdn.microsoft.com/en-us/library/aa710843(VS.71).aspx
And finally.... If you want to develop custom controls for Windows Forms applications...
http://msdn.microsoft.com/en-us/library/6hws6h2t.aspx
Well, this can be answered several ways. Most of the nice controls are doing a lot of Javascript that is not obvious unless you look at the output. You might be interested in using JQuery plugins (or "controls"). Also, to be honest, you might be interested in persuing a new way of doing ASP.NET, which is called ASP.NET MVC. This is a very good way forward of building Web applications that utilize a lot of Web standard technologies without hiding and obscuring the details. Here's a link to that:
http://www.asp.net/mvc/

Categories