Archive for March, 2012

How to deploy ASP.NET MVC3 application on the server?

Let us discuss how you can deploy ASP.NET MVC 3 application on server without any support from web hosting providers. .NET framework 4.0 is required to run MVC application. This approach does not require ASP.NET MVC 3 installation on the server.

Background:

When we install ASP.NET MVC 3 on a machine, required assemblies are automatically registered in Global Assembly Cache (GAC). GAC is a directory where .NET assemblies can be installed for global sharing. If we use shared hosting we might not be able to deploy these assemblies in GAC. Following simple steps will help you to deploy MVC application while using shared hosting services:

Manual method:

This is a manual way to deploy ASP.NET MVC 3 with Razor in BIN directory. When you run application in Visual Studio 2010 with .net framework 4 and MVC 3 installed on your machine the following folders are automatically created: C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3 C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages. These folders also contain an “Assemblies” folder. ASP.NET MVC references following additional assemblies: System.Web.Mvc Microsoft.Web.Infrastructure System.Web.Razor System.Web.WebPages System.Web.WebPages.Razor To deploy your application on shared server with no support from your hosting company you can simply copy these DLL files and paste them to your BIN folder.

Make DLLs local while publishing:

If you don’t want to copy these files manually or don’t have permissions to copy and paste these files you can use this method. The DLL files mentioned in the manual method can be included in the Bin folder when you publish your project to a production. To include them to the Bin folder, go to your MVC application project and expand the ‘References’ node in project tree. Select above assemblies then right click and select ‘Properties’ and change ‘Local Copy’ to True as it is False by default. If Local Copy attribute is set to TRUE then selected DLL will be included in ‘Bin’ folder when you publish your project.

Designing a division modal (Div Modal) Box Overlay

Designing a division modal (Div Modal) Box Overlay

Lets start with the designing of the overlay, before procedding with the overlay i would like to introduce why this overlay is named as such. as this overlay is designed using <div> tags used inside html programming language so i named it as such (you are free to name it as like you want)

there are four steps to design this overlay.

1.  Making an div overlay

2. giving it some attractive look

3. functioning of the overlay

4. Calling overlay on some action using mouse

here we goes with the design of the overlay :-

1.  Making an div overlay

<div id=”modalPage”>
<div>
</div>
<div>
<div>
<div><a href=”test.html”>X</a></div>
<div>
<p>i want to show the text box values here….</p>
</div>
</div>
</div>
</div>

Test.html is the name of the page where we are designign the overlay

2. giving it some attractive look

<style type=”text/css”>
body
{
margin: 0px;
}
#modalPage
{
display: none;
position: absolute;
width: 100%;
height: 100%;
top: 0px; left: 0px;
}
.modalBackground
{
filter: Alpha(Opacity=40); -moz-opacity:0.4; opacity: 0.4;
width: 100%; height: 100%; background-color: #999999;
position: absolute;
z-index: 500;
top: 0px; left: 0px;
}
.modalContainer
{
position: absolute;
width: 300px;
left: 50%;
top: 50%;
z-index: 750;
}
.modal
{
background-color: white;
border: solid 4px black; position: relative;
top: -150px;
left: -150px;
z-index: 1000;
width: 300px;
height: 300px;
padding: 0px;
}
.modalTop
{
width: 292px;
background-color: #000099;
padding: 4px;
color: #ffffff;
text-align: right;
text-decoration: none;
}
.modalTop a, .modalTop a:visited
{
color: #ffffff;
}
.modalBody
{
padding: 10px;
}
</style>

3. functioning of the overlay

<script language=”javascript” type=”text/javascript”>
function revealModal(divID)
{
window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
document.getElementById(divID).style.display = “block”;
document.getElementById(divID).style.top = document.body.scrollTop;
}

function hideModal(divID)
{
document.getElementById(divID).style.display = “none”;
}

</script>

4. Calling overlay on some action using mouse

<body>
<input id=”Button1″ type=”button” value=”Click here to be naughty” onclick=”revealModal(‘modalPage’)” />
</body>

so going with the pattern we used here to design the overlay the page layout and design using html programming language can be given as follows :-

<html>
<title>Divison Modal (Div Modal) Box</title>
<head>
<div id=”modalPage”>
<div>
</div>
<div>
<div>
<div><a href=”test.html”>X</a></div>
<div>
<p>i want to show the text box values here….</p>
</div>
</div>
</div>
</div>
<style type=”text/css”>
body
{
margin: 0px;
}
#modalPage
{
display: none;
position: absolute;
width: 100%;
height: 100%;
top: 0px; left: 0px;
}
.modalBackground
{
filter: Alpha(Opacity=40); -moz-opacity:0.4; opacity: 0.4;
width: 100%; height: 100%; background-color: #999999;
position: absolute;
z-index: 500;
top: 0px; left: 0px;
}
.modalContainer
{
position: absolute;
width: 300px;
left: 50%;
top: 50%;
z-index: 750;
}
.modal
{
background-color: white;
border: solid 4px black; position: relative;
top: -150px;
left: -150px;
z-index: 1000;
width: 300px;
height: 300px;
padding: 0px;
}
.modalTop
{
width: 292px;
background-color: #000099;
padding: 4px;
color: #ffffff;
text-align: right;
text-decoration: none;
}
.modalTop a, .modalTop a:visited
{
color: #ffffff;
}
.modalBody
{
padding: 10px;
}
</style>
<script language=”javascript” type=”text/javascript”>
function revealModal(divID)
{
window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
document.getElementById(divID).style.display = “block”;
document.getElementById(divID).style.top = document.body.scrollTop;
}

function hideModal(divID)
{
document.getElementById(divID).style.display = “none”;
}

</script>
</head>
<body>
<input id=”Button1″ type=”button” value=”Click here to be naughty” onclick=”revealModal(‘modalPage’)” />
</body>
</html>

and here is the div overlay looks like the design

that’s all ..

Different Ways to Install Applications On Android Without The Market

Installing apps on Android is relatively straightforward with the Android Market. You search for an app, select it and click install. However, there are often times when you may want to install a newly released app or an app that is not available in the Android Market. In these cases you will usually have to manually download and install an .apk file. An .apk file behaves in a similar manner to a “.exe” file on Windows, you need to copy it to your device and run it. Here are some ways that you can manually install an application without going through the market.

Enable Unknown Sources

Before attempting a manual installation of apps using the .apk files, you must first allow your phone to install from “Unknown Sources” (i.e. non-Market apps).

To do this, navigate to Menu -> Settings -> Applications and check the box marked “Unknown Sources“.

apkinstaller-unknown

1. Installing app Using The Conventional Method

Step 1: Install File Manager

Android does not natively come with any method of browsing the data on your SD card, so you will need to install a file manager from a market. There are a large variety of file managers available on Android, but my personal favourite is ASTRO File Manager.

astro file manager-main

Step 2: Copy .apk file to SD card

Once you have ASTRO File Manager installed, connect your Android device to your PC using your USB cable. Mount the SD card and copy over the .apk file you would like to install.

Step 3: Install .apk

On your Android device, navigate to the .apk file using ASTRO File Manager and select it.

This will open a dialog box allowing you to install the app. Select “Open App Manager“.

apkinstaller-app

On the next two pages, select “Install” and “Install” again to install the .apk.

apkinstaller-installapp

apkinstaller-appinstall

Your new app is now installed.

2. Installing app using Dropbox

Dropbox is really a versatile app and is a waste if we don’t fully utilize it. The method is simple. In your computer, download the apk file to your Dropbox folder. Let it finish syncing. In your phone, open the Dropbox app, navigate to the folder where you keep the apk file, click on it. Dropbox will then download the apk file. The usual installation follows.

3. Installing app Using the Online Apk Installer

The online apk installer is a web app created by a helpful XDA-Developers forum member htc-hd2, with the aim to make manual installation of an .apk file much easier. It is useful if you want to share an apk file with a friend.

Step 1: Upload File

First, navigate to www.apkinstall.com.

Here you will see a black “Browse Files…” button. Select this and choose the apk file on your PC.

apkinstaller-browse

The apk file will remain active on the website for 15 minutes.

Step 2: Scan QR Code

Once you have uploaded the file, a QR code will appear on the website.

apkinstaller-qrcode

You must scan this QR code with a Barcode Scanner. The website suggests using Barcode Scanner, however I personally prefer using Google Goggles.

apkinstaller-barcode

Once the QR code has scanned, you can click on the link to download the .apk file straight to your device.

Step 3: Install .apk

After the .apk file has downloaded to your Android device you can install it by simply clicking on it and navigating through the installation pages.

apkinstaller-download

Conclusion

Most users will probably be comfortable using the conventional method of installing Android apps. However, if you have a less tech-savvy friend who you want to share an apk with, you can always remotely upload it and send them the QR code to scan using their phone. This way they will not have to fiddle around with copying the apk to their phone and opening it using a file manager.

Let us know in the comments if you have been able to use this tool.

How to sign Android APK file using command line

To sign an APK file using Command line utility, is a three step process and is easy and simple to learn.

To sign an Android APK from command line use: –

  1. Sign the APK with jarsigner (using default keystore, android-root is the alias of the signing key):
    $ jarsigner -signedjar HelloWorld-new.apk HelloWorld-debug-unaligned.apk android-root
    Enter Passphrase for keystore: password
  2. Verify signature (optional)
    $ jarsigner -verify -verbose -certs HelloWorld-new.apk
  3. Align the APK (must use -v 4 option):
    $ ~/android-sdk-linux_86/tools/zipalign -v 4 HelloWorld-new.apk HelloWorld-new-aligned.apk

designing a Iphone UI interface using Jquery

Although there are lots of options we can design a mobile Phone interface using any language but there is an ultimate tool named jquery for giving your website a perfect UI. now we will discuss about the same.

Download iphone_unlock : Here

lets have a look over the code. here is the code for the same ..

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>iPhone Unlock Screen</title>
<link rel=”stylesheet” type=”text/css” href=”css/style.css”/>
<script type=”text/javascript” src=”js/jquery-1.2.6.min.js”></script>
<script type=”text/javascript” src=”js/ui.core-1.5.3.js”></script>
<script type=”text/javascript” src=”js/ui.slider.js”></script>
<script type=”text/javascript” src=”js/iphone-unlock.js”></script>
</head>

<body>
<div id=”iphone-scrollcontainer”>
    <div id=”iphone-inside”>
        <div id=”unlock-top”>
            <p id=”timepicker”>08:23</p>
            <p id=”datepicker”>Wednesday, July 6</p>
        </div>
        <div id=”unlock-spacer”>
            &nbsp;
        </div>
        <div id=”unlock-bottom”>
            <div id=”slide-to-unlock”></div>
            <div id=”unlock-slider-wrapper”>
                <div id=”unlock-slider”><div id=”unlock-handle”></div></div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

the js files included in the link tag of the head section describes the jquery files.

Download iphone_unlock : Here

Designing a Goog-Box Overlay using Thickbox Jquery

Designing a Goog-Box (i gave it a name) Overlay using Thickbox Jquery

Download Goog-box Overlay : Here

while we get start with the design let me explain what is the need for this overlay to design

1. html language

2. thickbox jquery files

3. language editor (i am using notepad ++)

the overlay consists of a main page which will be responsible to call our newly designed overlay into it to show up some of the designs. let we call this page as index.html. and htm5.htm is used for overlay look and html5check.html is used for showing some contents inside the overlay.

so please code these lines into your index file
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml&#8221; >
<head id=”Head1″ runat=”server”>
<title>Start</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″/>
<link href=”indexstyle.css” rel=”stylesheet” type=”text/css” />
<style type=”text/css” media=”all”>
@import “css/global.css”;
</style>
<script src=”js/jquery.js” type=”text/javascript”></script>
<script src=”js/thickbox_plus.js” type=”text/javascript”></script>
<style type=”text/css”>
.style1
{
height: 95px;
width: 159px;
}
body
{
height:auto;
width:auto;
font-family: Tahoma, Arial, Helvetica, sans-serif;
font-size:11px;
margin:0;
padding:0;
background-position:middle center;
color:black;
text-decoration:none;
}
span {
color:Black;
cursor:pointer;
text-decoration:none;
}
span:hover {
text-decoration:none;
}
a {
text-decoration:none;
}
a:hover {
text-decoration:none;
}
</style>
</head>
<body>
<table width=”100%” border=”0″ align=”center”>
<tr>
<td>
</td>
<td style=”height: 95px”>
</td>
</tr>
</table>
<div id=”font2″ style=”text-align: center”>
<hr style=”height: 1px; color: #000000;” />
<b><span style=”text-align:center”><span style=”font-size: 18pt; font-family: Verdana”>
DSProjects</span></span></b>&nbsp;
<hr style=”height: 1px; color: #000000;” />
<fieldset style=”width: 98%; height: 100%; text-align:center; vertical-align:middle; border:0;” visible=”false”>
<strong><span style=”font-family: Verdana; text-decoration: none;”>
<br/>
<a href=”Html5.htm?height=460&amp;width=775″ title=”confirm”>Check HTML5/CSS3 Compatibility</a> <br/>

</span></strong></fieldset></div>
<div id=”font3″ style=”text-align: left”>
<br />
</div>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″ style=”height: 1px”>
<tr>
<td valign=”top” style=”height: 31px; width: 3432px;”>
</td>
</tr>
</table>
</body>
</html>

which is covered by a style sheet document for giving it some UI and the files included in link tag are thick box jquery files (will let you give all of the files using zip link). by following the design we have got the design ike the image  :-

the link behind file is named as html5.htm which is responsible to give a design to GoogBox overlay using thick box jquery files.

The thick box file can be designed like the way :-
<head>
<title>Checking Tool</title>
<link href=”goog.css” rel=”stylesheet” type=”text/css”> <link rel=”icon” type=”image/ico” href=”/tools/dlpage/res/chrome/images/chrome-16.png”> <link rel=”icon” href=”http://www.erlsindia.co.in/images/favicon.ico&#8221; type=”image/vnd.microsoft.icon” /><link rel=”icon” href=”http://www.erlsindia.co.in/images/favicon.ico&#8221; type=”image/vnd.microsoft.icon”/><script language=”javascript” src=”http://www.erlsindia.co.in/js/DisableCtrlU.js”></script><script type=”text/javascript”>document.oncontextmenu=new Function(“return false”);</script></head> <link href=”dlpage.css” rel=”stylesheet” type=”text/css”>   <script type=”text/javascript” src=”gu-util.js”>
</script> <script type=”text/javascript”>
function runTagParamsHook(tag, opt_guid) {return tag;}
function runThankYouQueryHook(query) {return query;}
function runGetAppsPageHook(apps) {return apps;}
var referer = “http://www.google.co.in/chrome?hl/x3den/x26brand/x3dCHMI&#8221;;
function resetButtons(name) {
var buttons = document.getElementsByName(name);
for (i = 0; i < buttons.length; ++i) {
buttons[i].disabled = false;
}
}
function showThrobber(isVisible) {
var divThrobber = document.getElementById(‘throbber’);
var imgThrobber = document.getElementById(‘throbber-img’);
if (!divThrobber || !imgThrobber) {
return;
}
if (!isVisible) {
divThrobber.style.display = ‘none’;
}

imgThrobber.src = isVisible ?

“chrome_throbber_fast_16.gif”/*tpa=http://www.google.co.in/tools/dlpage/res/chrome/images/chrome_throbber_fast_16.gif*/

: “”;
if (isVisible) {
divThrobber.style.display = ‘inline’;
}
}

function getApps() {
var apps = new Array();
apps.push(_GU_createAppInfo(
“{8A69D345-D564-463C-AFF1-A69D9E530F96}”,
“Erls ElementSix”,
“false”,
runTagParamsHook(
“\x26brand\x3dCHMI\x26installdataindex\x3dhomepagepromo”,
“{8A69D345-D564-463C-AFF1-A69D9E530F96}”)));
return runGetAppsPageHook(apps);
}
function areStatsEnabled() {
var statcb = document.getElementById(“statcb”);
return (statcb && statcb.checked);
}

function sendDlPagePing(stage, installSource) {
var img = new Image();
var extra = GU_buildGlobalExtra(
“en”, areStatsEnabled());
var tag = GU_BuildTag(getApps(), extra);
img.src = ‘//tools.google.com/service/update2/dlpageping?’ +
tag +
‘&stage=’ + stage +
‘&installsource=’ + installSource;
}

_GU_OnloadHandlerAdd(
function() {
if (isOneClickEnabled()) {
_GU_SetupOneClick();
}
}, 0); // front of list

_GU_OnloadHandlerAdd(
function(pagename) {
sendDlPagePing(pagename, getInstallSource());
});  // added to end of body.onload handler list

function runGetAppsPageHook(apps) {
try {
var app = apps[0];
if (_GU_isOneClickAvailable() &&
window.google.update.oneclick.getInstalledVersion(app.guid, true)) {
app.needsAdmin = true;
}
} catch (err) {
}
return apps;
}

</script>  <script type=”text/javascript”>
function goCancelled() {
this.document.close();
}

function getConfigOptions(tag) {
try {
if (tag.match(/installdataindex=([^&]+)/) && document.configOptions
&& document.configOptions.cboption1.checked) {
return tag.replace(/installdataindex=([^&]+)/,
‘installdataindex=$1-defaultbrowser’);
} else if (document.configOptions
&& document.configOptions.cboption1.checked) {
return tag + ‘\x26installdataindex\x3d’ + ‘defaultbrowser’;
} else {
return tag;
}
} catch (e) {
return tag;
}
}
function runTagParamsHook(tag, opt_guid) {
return getConfigOptions(tag);
}
function runThankYouQueryHook(query) {
query = query || ‘\x3f’;
return getConfigOptions(query);
}
</script>
<div id=”container”><noscript>You need a JavaScript-capable browser to download this software. <a href=”#”>Click here for instructions</a> on how to enable JavaScript in your browser.</noscript>  <div id=”header” style=”height: 5px”> </div> <div id=”main”> <div id=”tos”>http://Html5Check.html <br> <p><a href=”#”>Printer-friendly version</a></p>  <div style=”position: relative; width: 100%; left: 1px; top: 2px;”><div id=”throbber”><img id=”throbber-img” width=”16″ height=”16″ alt=”” src=”ajaxImage.jpg”></div> <div style=”display: inline;”></div> </div></div></div> </div>

and a iframe is used to show up some of the contents inside page to give some design as :-
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head id=”Head1″ runat=”server”>
<title>ECheck</title>
<link href=”indexstyle.css” rel=”stylesheet” type=”text/css” />
<style type=”text/css”>
span {
color:Black;
cursor:pointer;
font-weight:bold;
text-decoration: none;
}
span:hover {
text-decoration:none;
color:blue;
}
</style>
</head>
<body>
<div id=”font2″ style=”text-align: center”>
</div>
</body>
</html>

That’s it what we wanted to design is our googBox Overlay using thickbox Jquery.

Download Goog-box Overlay : Here

How to access a MySQL database with .NET

An often overlooked combination of scripting technologies is ASP.NET with MySQL (instead of Access [slow] or SQL Server [expensive]). MySQL is a fast and popular database and you can find numerous ISPs which offer it with ASP.NET

If you are installing it on your own server, you need to download MySQL and install it, then run c:\mysql\bin\winmysqladmin.exe. You also need to download the ODBC driver (choose Windows Downloads Driver Installer) and install it. Then use this code to access your MySQL database.

<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Odbc" %>
<%@ Page Language="C#" %>
<script runat="server">
public void Page_Load(Object sender, EventArgs e) {
DataTable dtRecords = GetDataTable("SELECT * FROM newone");
foreach(DataRow dr in dtRecords.Rows) {
Response.Write(dr["FirstName"].ToString() + " " + dr["LastName"].ToString() + "
");
}
}

private static string GetConnection() {
return “DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Database=testdatabase”;
}
public static DataTable GetDataTable(string sql) {
DataTable rt = new DataTable();
DataSet ds = new DataSet();
OdbcDataAdapter da = new OdbcDataAdapter();
OdbcConnection con = new OdbcConnection(GetConnection());
OdbcCommand cmd = new OdbcCommand(sql, con);
da.SelectCommand = cmd;
da.Fill(ds);
try {
rt = ds.Tables[0];
}
catch {
rt = null;
}
return rt;
}

</script>

 

%d bloggers like this: