Monday, February 9, 2015

Create Android Application using Visual Studio

What you need to know

If you know simple HTML and JavaScript then Congrats you can develop a Android (Cross platform too) application.

Prerequisites 
1. Visual Studio 2013 Update 4
2. Visual Studio Tools for Apache Cordova - CTP3

Let's start with simple Hello Android Program

As usual start from Create Project - > Templates - > Javascript - > Apache Cordova Apps



After successful creating project our Solution explorer look like this







































Now open index.html (This is simple HTML file). Change the line "Hello, your application is ready!" to "My First Android Application" and Run application. For the first time application take time to compilation and packaging. Wait to complete this process. The browser screen will open with the help of Ripple and will show you output like this



Now Congrats guys you successfully created a android app. Now just running in the browser is not functionality of Android app. Android app should run on android mobile. As all we know APK is extension of android app. Here we need to do some tweak, some configuration changes. It's called Signing your app.

Signing Your App Manually
You can sign your app from the command line using standard tools from the Android SDK and the JDK. To sign an app in release mode from the command line:

Generate a private key using keytool. For example:


 keytool -genkey -v -keystore my-release-key.keystore-alias alias_name -keyalg RSA -keysize 2048 -validity 10000

This example prompts you for passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore. The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app.
The .keystore file will be created in the same bin directory. Copy it and paste it in the  Our Appliction - > res -> native- >android.
Now change the "ant.properties" file which is in same directory.

key.store=keystorefilename
key.alias=alias
key.store.password=Pa55w0rd
key.alias.password=Pa55w0rd


And we are done. Build project in Release or Distribution mode. You will find your apk file in your Application directory - > bin -> Android -> Release - > CordovaApp-release.apk

Now this application is ready to install on any android mobile. Try yourself. 

Thursday, July 26, 2012

Enable/Disable Asp.net Button using jquery

To enable
 $('#btnTransferPatient').attr('disabled', false);
 $("#btnTransferPatient").removeClass('aspNetDisabled');

To disable
$('#btnTransferPatient').attr('disabled', true);
$("#btnTransferPatient").addClass('aspNetDisabled');

Wednesday, May 9, 2012

Imporatant Validation Expression


1. Only alphanumeric with space
[^\w\s]

                

Thursday, April 5, 2012

Validate Date of Birth

protected void Page_Load(object sender, EventArgs e)
        {
              rvSearchDOB.MaximumValue = DateTime.Now.ToString("d");
        }

<asp:TextBox runat="server" ID="txtSearchDOB" />&nbsp;<asp:Image ImageUrl="~/Images/calender_btn.png"
                    runat="server" ID="imgCal" ImageAlign="AbsMiddle" />
                <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtSearchDOB"
                    Format="d" PopupButtonID="imgCal" />
                <asp:CompareValidator ErrorMessage="Invalid date format. Use (mm/dd/yyyy)" Display="None" ID="cvSearchDOB"
                    ControlToValidate="txtSearchDOB" Operator="DataTypeCheck" Type="Date" runat="server" ValidationGroup="grpSearchSubmit" />
                <ajaxtoolkit:ValidatorCalloutExtender ID="vcSearchDOB" runat="server" TargetControlID="cvSearchDOB"
                    PopupPosition="TopLeft" Enabled="True"  />
                <asp:RangeValidator ID="rvSearchDOB" runat="server" ControlToValidate="txtSearchDOB"
                    MinimumValue="1/1/1900" MaximumValue="1/1/2100" Type="Date" Text="Invalid Date"
                    Display="None" ValidationGroup="grpSearchSubmit" />
                <ajaxtoolkit:ValidatorCalloutExtender ID="vcretxtSearchDOB" runat="server" TargetControlID="rvSearchDOB"
                    PopupPosition="TopLeft" Enabled="True" />

Wednesday, April 4, 2012



With this simple jQuery function, you can notify a user if they’ve made any un-saved changes to a form field – and give them a chance to save or discard those changes. I was recently able to try this out on a work project and it is working beautifully.
I have a feeling THIS will come in very handy for a variety of projects.



var isDirty = false;
var msg = 'You haven't saved your changes.';

$(document).ready(function(){
   $(':input').change(function(){
      if(!isDirty){
         isDirty = true;
      }
   });

   window.onbeforeunload = function(){
      if(isDirty) {
         return msg;
      }
   };
});



Change the ValidatorCalloutExtender ErrorMessage

Change the ValidatorCalloutExtender ErrorMessage


sender.errormessage = "Please select atleast one Quintile.";
                        var cell = sender.ValidatorCalloutBehavior._errorMessageCell;
                        // cell is going to be null first time.                       
                        if (cell != null) {
                            cell.innerHTML = "Please select atleast one Quintile.";
                        }

Monday, April 2, 2012

Select-all checkbox Jquery for ASP.NET GridView,DataList,Repeater etc.

Scenario
1.On Parent check box Selecting, All - Child check boxes should be checked.
2.On Manually Selecting all child check boxes, parent should be checked.
3.Deselecting one of the child check box Parent should be deselected

Markup Code for Reapeter
same thing can be done using Gridview or DataList also.
I have used only cssclass for selecting appropriate control so you don't have to worry about what html parsing id's of checkboxes.


 <asp:Repeater ID="rpSections" runat="server">  
           <HeaderTemplate>  
             <table class="def_table" width="100%">  
               <tr>  
                 <th>  
                   <asp:Label runat="server" ID="lblQuestionnaireTypeHeader" />  
                 </th>  
                 <td align="left">  
                   <asp:CheckBox ID="cbCheckAll" runat="server" CssClass="chkHeader" />  
                 </td>  
               </tr>  
           </HeaderTemplate>  
           <ItemTemplate>  
             <tr>  
               <td>  
                 <%# DataBinder.Eval(Container.DataItem,"Section.SurveyName" ) %>  
               </td>  
               <td>  
                 <asp:CheckBox ID="chk" runat="server" CssClass="chkItem" />  
               </td>  
             </tr>  
           </ItemTemplate>  
           <FooterTemplate>  
             </table>  
           </FooterTemplate>  
         </asp:Repeater>  

Jquery code (don't forget to add jquery reference)

  <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.js" type="text/javascript"></script>