Friday 13 June 2014

Difference between @Html.TextBox, @Html.TextBoxFor & @Html.EditorFor

These are html helpers, which renders html input tag in which the type attribute is set to text.

@Html.TextBox("example")
 
This is the basic format of html helper for textbox. The html
 
 

@Html.TextBoxFor("example")

@Html.EditorFor("example")

Saturday 7 June 2014

Debugger not activated - Firebug

  • Open the Firebug window.
  • Click on the Firebug icon in the upper-left corner of the window and go to the menu item:
       Options > Reset All Firebug Options
  • Activate Firebug.

Friday 6 June 2014

The database '*\DATABASE1.MDF' cannot be opened because it is version 706. This server supports version 655 and earlier. A downgrade path is not supported. Could not open new database '*\DATABASE1.MDF'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 948)

  • Version 706 is a database file from Sql Server 2012
  • Version 665 is a database file from Sql Server 2008R2



Tortoise workbench ignore certain files with hgignore

There may be cases where we want to ignore certain files before committing in mercurial distributed revision control system. We can ignore files using hgignore file.

  • hgignore file resides in the root folder.
  • Open the file
    • Right - click on file and open (CTRL + SHIFT + T). OR
    •  Take terminal from Repository tab and type 
      • thg hgignore
  •  If opened from the terminal

 
hgignore window


  •  Add file path or file extensions and add in the file.
  • It will take into effect after first commit.
  • After adding the restriction rules you can add hgignore file using
    • hg add .hgignore

Wednesday 19 March 2014

Logging Tools Log4Net vs ELMAH

Both needs configuration files.

Log4Net

  • Simple general purpose logging tool.
  • Easy to integrate.
  • Creates text file.
  • Log levels: DEBUG, INFO, WARN, ERROR, FATAL.

Pros
  1. Highly configurable logging framework.
  2. Best used by calling explicitly through code.
  3. Can implement exception handling with handlers.
  4. Output: file, console, email.
  5. Thread-safe.
  6. Will not throw unexpected exceptions at run-time potentially causing application to crash.
Cons
  1. Not reliable.

ELMAH (Error Logging Modules And Handlers)

  • Logging and notification of unhandled exceptions.
  • Since it handles all unhandled exceptions, log level is always ERROR.
  • Ability to display a  list of errors and the details of a specific error from a web page.
  • View exceptions via different mechanisms (SQL, RSS, Twitter, files, email etc).
  • Customize filtering logic.
  • Custom HandleError with ELMAH Attribute in ASP.NET MVC

Pros
  1. Good for reporting overall errors and unhandled exceptions.
  2. No change in application code for implementing ELMAH.
  3. Few configuration change.
  4. Good solution for YSOD (Yellow Screen Of Death).

Cons
  1. Can go complex.
  2. Only used for exception messages.


Log4Net - ELMAH - Appender
  • Communicate with ELMAH library on behalf of Log4Net.
  • Adds the ability to make Log4Net entries routed to ELMAH

Thursday 13 March 2014

Remove first character from string C#

Use substring() method.

string str = "/a.txt";
str = str.substring(1);


Output

a.txt

URL querystring with multiple parameters not working - Browser compatibility Issue

When passing multiple parameters as query string, the redirection will work properly in Internet Explorer. This is because the special character '&' is escaped automatically.

But in Mozilla, Chrome it will not work.
www.example.com/controller/action?a=1&b=2

In order to work we need to escape the ampersand special character using Razor syntax @Html.Raw(string).

www.example.com/controller/action?a=1&b=2


iOS

Cannot install applications because the certificate is not valid. - iOS 7.1 Enterprise App

Is it rediculous? May be or not. Might be for more security.

Any way this error is showing in iOS 7.1. When we see this in first time we will get confused.

Install error
Error

The above alert is coming while installing applications in iOS 7.1.


Analysis

From iOS 7.1 Apple is enabled additional security feature, that the enterprise apps manifest file (.plist) to be served with HTTPS. Only the .plist file needs to be in HTTPS format.

Solution


Since the URL for the plist file must be in HTTPS format you need to obtain a valid SSL certificate.
In IIS we can create self-signed certificate which will not work for creating plist url.

If you are not having any valid SSL certificate in your server, you can upload plist file in dropbox and create a https format url for plist in order to work in iOS7.1.

In dropbox the link created will be

https://www.dropbox.com/s/glwllqmnwutl2rm/test.plist

Change www.dropbox.com to dl.dropboxusercontent.com, and add to the url.So it will become

https://www.dl.dropboxusercontent.com/s/glwllqmnwutl2rm/test.plist

Add this HTTPS format to the OTA (Over The Air) link, it becomes:

itms-services://?action=download-manifest&url=https://www.dl.dropboxusercontent.com/s/glwllqmnwutl2rm/test.plist










Saturday 1 March 2014

How to check .NET Framework version installed in your PC

For checking which .NET Framework is installed in your PC, follow the below steps

Steps:
  1. Click on Start.
  2. Type regedit in  Search and files area.
  3. You will see Registry Editor popup window.
  4. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework.
You will see different version which are already installed.
Check the latest version installed in your PC. :)



Monday 24 February 2014

Cross platform mobile development tools

Pros
  • Code reusable.
  • Easily accessible to plugins.
  • Easy for web developers.(HTML5, CSS3)
  • Reduce development cost.
  • Support for enterprise and cloud services.
  • Easy Deployment.

Cons

  • Might not support every features of OS or device.
  • Can’t Always Use Your Own Tools: Most frameworks want users to use their own development tools and suites, and that can mean that a developer has to forgo his or her own IDE preferences and use something else. PhoneGap (which Adobe acquired last summer) is different in this regard; in that it uses the native IDE for each platform it supports (XCode for iOS, Eclipse for Android, Visual Studio for Windows Phone).
  •  High end graphics and 3D support is often limited.
  • Vendor lock-in : Most of the cross-platform frameworks build using their own subsets of JavaScript, which means that if you want to switch to another platform, that code you wrote before is likely not going to be reusable without a lot of work.
Rhodes:
  • Open source Ruby based framework.
  • Achieves cross-platform by providing a runtime environment wrapped around the native app.
  • The runtime VM is ported to different platforms, abstracts the communication between device and app.
  • MVC development pattern. Only framework that supports MVC.
  • IPhone, Android, RIM, Windows Phone 7 windows mobile (4 platforms)
  • Object relational mapper component(Rhom)
    • Mini ORM(object relational mapper).
    • High level way to create local database easier to program to.
    • Database is SQLite on all platforms except BlackBerry where it is HSQLDB.
      Supports two model types: Property bag/ Fixed Schema.
    • Property Bag:  all data stored in single table using object-attribute-value pair( Entity-Attribute-Value model).
    • Fixed Schema: each model will have separate table and each attribute exists as a column in the table.
    • UI – HTML, JavaScript, CSS, JavaScript UI frameworks.



  
           installs all Rho products, and provides an IDE for Rhodes and RhoConnect development.

  •  Eclipse installation for developing Rhodes Application.
  • Installs Rhodes development suite; Rhodes, RhoConnect.
  • Generate Rhodes application(s).
  • Generate Rhodes Model(s) and associated Controllers and View templates.
  • Generate RhoConnect applications.
  • Generate RhoConnect source adapters.
  • Manage build configuration (build.yml and rhobuild.yml) using the RhoStudio/Eclipse UI.
  • Build, run, and debug your application in the RhoSimulator.
  • Build and run your Rhodes application on iPhone, Android, Windows Mobile, and BlackBerry simulators and devices.
  • See the build and application execution logs in the Eclipse output console.
 

  • Synchronization Framework.
  • REST API.
  • Administration web console.
  • Asynchronous Job System.
 a synchronization framework consisting of a backend application (a client component on the mobile device) and a server component (a RhoConnect application) that runs on any server capable of running Ruby.   
  • RhoConnect requires that you write a small amount of code for the query, create, update and delete operations of your particular enterprise backend. You can write this code in Ruby as a RhoConnect source adapter, or you can write this code as a RhoConnect plugin application written in Java, .NET, or Ruby on Rails. 



  • Build online without installing iPhone sdk locally.
  • Can build complex codes from windows machine for iphone.
  • Rhohub cloud platform lets developers to work on both Mac and windows for all mobile platforms.
  • Option to convert app to any mobile platform, online.
              RhoGallery?



  • Handles all the work of connecting to enterprise back-end applications.
  • The alternative that is done with most iPhone Objective C or other framework-based apps is to do all the code to connect to backend applications yourself: connecting to the backend web service in SOAP or REST, retrieving the data as XML or JSON, parsing the data and populating and managing the local device database. Objective C developers tell us that they spend more than 50% of their app code on these tasks. RhoSync removes all of this effort.

Reference

http://www.rhomobile.com/blog/modern-app-development-goodness-for-native-apps-what-rhodes-offers-that-no-other-framework-or-underlying-sdk-does/





Phonegap

  • Developed by Nitobi now acquired by Adobe.
  • Standards-based, open-source development framework for building cross-platform mobile apps with HTML, CSS and JavaScript for iPhone/iPad, Google Android, Palm, Symbian, BlackBerry, Windows Mobile and more.
  • Supports 7 mobile OS – Apple iOS, Android, WebOS, BlackBerry, Windows, Symbian and bada.
  • Development environment. DreamWeaver CS5.5 has built-in PhoneGap framework. IDE like Eclipse and XCode supports PhoneGap.
  • MVC
    - Model = PhoneGap JS API + offline storage/cache
    - Controller = JavaScript
    -  View = HTML + CSS
  •  HTML for layout ( Better yet HTML5 ).
  • JavaScript for accessing device functionality.
  • CSS for rich look and feel. ( Better yet CSS3 ).
  • Phonegap apps are just webpages that access device functionality.
  • Rich UI. Supports javascript frameworks.
    • Images are usually loaded from the device, so it's quick.
    • Interaction is quick if you use touch events instead of click events.
  •  Architecture of App
    • Server component.
    •  Javascript calls the server via XHR to get the JSON data.
    • Javascript can stored retrieved data in SQLite database for offline access. Can cache images.
  •  Different from mobile website?
    •  Mobile websites are domain restricted to their origin url and cannot access other sites/APIs.
    •  PhoneGap applications are loaded from the file:// protocol so server requests are NOT restricted.
    •  With PhoneGap you can build powerful mashups accessing multiple services.

Limitations

  •  Complex games, intensive graphics. Use OpenGL for that, not PhoneGap.
  •  For slower phones (not iPhone, not Nexus One, not Xperia X10), PhoneGap apps using the latest interactive Google Maps APIs tend to be slow. Static maps OK, though.
 Reference

http://savagelook.com/blog/portfolio/8-things-to-know-about-phonegap
http://geekyfry.com/topics/tech-it/smartphones/phonegap/
http://savagelook.com/blog/portfolio/a-deeper-look-at-appcelerator-and-phonegap
http://www.slideshare.net/inouemak/rhodes-and-phone-gap
http://groups.google.com/group/phonegap/browse_thread/thread/f23fedaa06abd3b8/2c5005410e7da4e0


Appcelerator

  • while using the familiar JavaScript syntax, developers will also have to learn the Titanium API, which is quite different from familiar web frameworks such as jQuery.
  • is sometimes compared to Adobe Air for developing desktop applications.
  • Titanium Studio is a full open standards IDE that is derived from Aptana Studio.
  • Offers cloud based services for packaging, testing and distributing software applications developed on the Titanium platform.
  • Supports HTML,CSS, Javascript on all platforms and PHP, Ruby, Python for desktop platforms.
  • Supports various javascript frameworks.
  • API access to UI components and geolocation, maps, accelerometer.
  • Extensibility through open interfaces, licensing, support for other scripting languages,  media codecs.



jQuery Mobile = Unified UI system for myriad mobile devices. (layout/animation/interactivity)
Phonegap = library to access native hardware APIs.
jQuery Mobile + Phonegap = UI + Native Functionality.
SenchaTouch and JQueryMobile are both javascript mobile UI libraries. Their approaches to development and device support are very different,  but both can be used to construct the UI for mobile apps and should be considered peers.

You could also consider  other such libraries such as YUI3, dojo or even with appropriate licensing - Enyo from Palm/HP.
Phonegap can be used with any of these UI libraries to package the web.
UI for delivery as native apps with full access to phonegap APIs.


HTML Tags - DIV vs TABLE instead of DIV or TABLE

DIV/TABLE are HTML tags which can populate data inside the markup language. Most of us have come across the situation, where we have to choose between DIV and TABLE. Both have there own way of presenting data inside the HTML. Ofcourse TABLE tag gives easier way of displaying data like, showing a weekly/monthly/yearly report with legible heading for each column, any tabular data etc. So is it possible to use DIV instead of TABLE in the above example?, yes it is possible. Its hard for a beginner to go with a DIV, because inorder to make a perfect aligning of DIV, some styling basics (Cascading Style Sheet – CSS )also should be known. 

 Comparison

DIV TABLE
Loads faster. Loads slower.
Quite few tags needed (div). More tags needed (table , tr, td, thead , tfoot ,th).
Make use of Search Engine Optimization (SEO) more powerful. Less powerful.
Reduce size of the page significantly. Page size increases.
Flexible. Inflexible.
Styling issues compromised using CSS. Only partially.

 
DIV and SPAN tags

DIV which creates a division inside html content. Usually used to dynamically populate data, using AJAX calls.SPAN also creates a division. The main difference between these two is that
  • DIV creates a line break after the tag is closed.


Example 1


Example 2


Output

Example 1
Example 2

Inorder to make this in single line. This need to be changed to:




Example 1


Example 2




Output

Example 1 Example 2

  • SPAN will not create any line breaks. Usually SPAN is used for styling text with the help of CSS.

    Example 1
    Example 2


    Output

    Example 1Example 2

Methods for passing values from one page to another

1. '''Query String''' ['''''GET Method''''']

Passing variables using query string, which means the values are passed along with the URL.

http://www.example.com/page2.php?a=2&b=4&c=6


This can be achieved using one of the form method submission 'GET'.
So You can see that using GET method the values can be sent through query string, and ofcourse the key-value pairs are 'visible' to the user as well. So it is restricted to sent very sensitive data like password and other secured data from one page to another.
In page1.php









The browser divides the URL into parts and recognizes a host, then sends to that host a GET request with the rest of the URL as argument. The server takes it from there. Here the form data are restricted to ASCII codes. Special care should be taken to encode and decode other types of characters when passing them through the URL in ASCII format.

All form data filled in is visible in the URL. Moreover, it is also stored in the user's web browsing history/logs for the browser. These issues make GET method less secure.

One advantage of form data being sent as part of the URL is that one can bookmark the URLs and directly use them and completely bypass the form-filling process.Length of the URL is limited



2. '''Passing as hidden''' ['''''POST Method''''']







The above form when submitted, it calls
this URL - http://www.example.com/page2.php , in which the key-value
pairs are sent as hidden.

GET POST
Caching/Bookmark Can be bookmarked. Can not bookmarked.
Security Less secure. More safer.
Type of data Sent via URL string,so data can be text only(only ASCII characters) Text as well as binary data('enctype' attribute with a value "multipart/form-data" ).
Data length Limited. Unlimited.
Submission If the page is refreshed it would not prompt before the request is submitted again. It would prompt before the request is re-submitted.


3. Using COOKIE/SESSION

Before going into that what is the difference between cookie and session?

Cookies - piece of information that a website stores on its client machine, and can be used to keep track of your movement from page to page so you dont need to enter the information that you've already given to the site. But the thing is that, you can save only less amount of data and also storing anything sesitive in the client machine makes anyone to tamper it. So it seems insecure.

Session - which is stored in server side, more secure while using sesitive data.

Can use both the combination of cookie and session to make the website work as the way developer wanted.

== ''When and Where to use these?'' ==


In cases like validating login credentials we can use both cookie and session.

When we storing the login credentials like login username and password into cookie variable it will get stored in the browser so user do not have to re-login to the website every time he visit. That is no need to re-submit login credentials again and again.
Since it is stored in browser, the user can block cookies or delete them at any time. Problem with sessions is that when you close your browser you also lose the session.Session id created will be different each time.

Another situation arises in the case of a shopping cart.
If you are using cookie for storing cart variables and a user had their browser set to block them, then he could not shop in the website. Since the cart variables is to be updated in database, it should be set using a session.