Tuesday, November 12, 2013

Create First Web API Application

For Creating Web Api first check you have MVC 4  version installed on your machine.

First select new Porject and select MVC4WebAppliction.

After thet select Web API under next wizard. after creation this will look like below image

For creating API we need to workin only one controller file i.e. ValuesController. I have created single get method for learning puspose First Create Customer Class file under model and refrence to on your controller file

After Implementation of Get Methods you need to execute/test this page, you will found API URi like this...


After success full creation of Web APi now its time to integrate this on your application.

For demo purpose i have created a page in a same project you can implement this on any other sites also.

In my case for Accessing the created API  need to create Controller APITestController and View for viewing purpose just like below image

once you created the view page now you need to write some code for accessing the API, for example i am writing here in jQuery like below image

Thursday, November 7, 2013

Update All Column Values of a table in SQL

You can very easily generate SQL to do the updates, to save you a lot of typing. You can whip up something like this very quickly:


Just replace "Name" with the name of your table, and run. Copy the output into a SQL Server Query Manager window, and run it.
The above will update every column of every row in the table to be NULL where the column contains exactly one space.

Tuesday, November 5, 2013

Open link in new window or tab using Javascript

  <script type="text/javascript" language="javascript">
    function MM_jumpMenu(targ, selObj, restore) { //v3.0
       if (selObj.options[selObj.selectedIndex].value.indexOf("http:") >= 0) {
           eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
           if (restore) selObj.selectedIndex = 0;

 <select onchange="MM_jumpMenu('window.open()',this,0)" size="1" id="width" name="Width">        
      <option>Select an Option</option>
      <option>Child Plan</option>
      <option value="http://google.co.in">--Google</option>
      <option value="http://www.maxlifeinsurance.com/Plans/insurance-plans/child-insurance/shiksha_plus.aspx">--Shiksha Plus II</option>
      <option value="http://www.maxlifeinsurance.com/Plans/insurance-plans/child-insurance/college-money-back.aspx">--College Plan</option>

     <option>Growth Plan</option>
    <option value="http://www.maxlifeinsurance.com/Plans/insurance-plans/child-insurance/shiksha_plus.aspx">--Flexi Fortune</option>
    <option value="http://www.maxlifeinsurance.com/Plans/insurance-plans/growth/fasttraclplan.aspx">--Fast Track</option>