Sunday, 15 November 2015

Create your own extension in Google Chrome Browser


  • Hi all, this article will teach you how to create an extension in Chrome browser. It's very easy you just have to do is follow my steps.
  • Now since Google Chrome works with JSON we'll create a .json extension file in one of the folder as shown.


















  • Now in that file enter following code and save it.

{
  "manifest_version": 2,

  "name": "Youtube Watcher",
  "description": "Watch Videos of youtube",
  "version": "1.0",

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  }
  
}
  • Now create one html file named popup.html in same folder in which we'll enter following code:
<iframe width="560" height="315" src="https://www.youtube.com/watch?v=UcBn995_tZo" frameborder="0" allowfullscreen></iframe>
  • Thereafter we'll create one icon for youtube extension  named icon.png where you can save the youtube icon in this image file.
Note : All three files should be in Same folder as shown.




















  • Now open your Chrome browser and goto->More Tools->Extensions->Check the Developer Mode.
  • Now click Load unpacked extensions and select the folder where you have kept all this 3 files.
  • It will automatically load your youtube extension.
  • You can change anything you want if you are a json expert.











  • Thanks, I'll like share you this kind of stuff again.

Saturday, 14 November 2015

CRUD operations in ASP.NET MVC 5 using C#


  • This article is for beginners and it's for performing the CRUD operation in ASP.NET MVC 5 using C#. And in next article we'll see Searching, Paging and Sorting a table
  • Note :Download the Visual Studio 2013 or higher so you can grab all the latest features.
  • First create a new project in Visual Studio( * in this article 2013 is used) and give appropriate name to it.

  • Now after clicking OK one new window will prompt, where it will ask to choose the template. Simply select the empty template and check the MVC as shown in below picture.
  • Now after clicking OK, blank ASP.NET MVC solution will be created.

  • Before moving forward you need to create a database in Sql Server. I've created a database named TestDB and a table EmpDetails that contains EmpId, EmpName, EmpAdd, EmpNumber field.


  •  Now for connection of MVC to database we'll use Entity Framework . So we'll goto Tools-> Nuget Packet manager and install the Entity Framework package in our solution. After installation you will see this kind of view.

  • Now we'll add the Model(i.e. Class.cs) in Model Folder. Let us name it as EmpDetails.cs. And add namespace :
    1. using System.Data.Entity;
    2. using System.ComponentModel.DataAnnotations;
    3. using System.ComponentModel.DataAnnotations.Schema;
        • Now mention the table name and key as shown in Class file as per your need.



        • Now add a connection string to the web.config file as shown and make sure that the connection string name is same as of DBContext Entity.... here in my program it is EmpDBContext.




        • Now model has been created and we'll create a controller for action.But before creating the controller you've build your application once to effect the changes. So, here's a MVC 5 scaffholding part where you didn't have to do any code scaffholding will do by itself. You just have to do is select the controller by going to Controller Folder-> Add -> Controller-> Select MVC 5 Controller with views, using EntityFramework.
        • After selecting , window would be prompted which would ask for Model Class select your Model Class, then select the data context. And controller name would be taken automatically. Click Add. The scaffholding process would be going on which will create one controller named EmpDetailsController.cs in Controller Folder and simultaneously it will also create a View for EmpDetails controller where you would see the Create, Delete, Details, Edit and Index.cshtml files in Views-> EmpDetails folder as shown


        • Now just goto->AppStart->RouteConfig.cs and change the controller from Home to EmpDetails and run the applications.
        • You will get the output where there would be one table and you can Create , view delete the data of the table.
        This is how an easy to develop  Application in MVC 5 is done and is quite simpler. For understanding the details code you can go through class file generated in Controller. In next article we're going through that. Have a nice development.





        Tuesday, 3 November 2015

        Generate random numbers from List in c# using Linq


        • This article is to demonstrate how to generate the random number from the generic List<T> using Linq.
        • First of all we'll create the list of results which is in ascending order.
        • Then we'll select each record from the results, ordered by Guid each time.This gives randomness.
        • Thereafter we'll return the list.



        • Finally access the list however you want.

        Sunday, 18 October 2015

        Uploading files larger than 5 mb in ASP.NET


        • One of the small stuff that some of the freshers are messing with is uploading the file of size larger than 5 MB or more.
        • It is really so easy to resolve, the thing you need to do is just add a <httpruntime/> tag to your web config file under <system.web> as shown and that's it done.

        • You may change the size 16384 (16 MB) to what ever you want e.g 4096, 8192 or 65536 (64 MB).
        • Enjoy the coding.

        Friday, 2 October 2015

        Access the .NET Server Controls using javascript easily


        • There are many developers that are depend on intellisense provided by Microsoft Visual Studio.
        • But some times it may not work for scripting, though in VS 2012 and higher version it quite run much good.
        • So here are some of the JS code that I would like to share with developers for accessing the .NET controls and how to retrieve and set value to controls.
        • Get Label Value:
        • $('#<%=Label.ClientID%>').text();
        •  Set label value:
        • $('#<%=Label.ClientID%>').text("New Value");
        •  
        • Get Textbox value:
        • $('#<%=TextBox.ClientID%>').val();
        •   Set Textbox value:
        • $('#<%=TextBox.ClientID%>').val("New Value");
        •  Get Dropdown value:
        • $('#<%=DropDownList.ClientID%>').val();
        •  Set Dropdown value:
        • $('#<%=DropDownList.ClientID%>').val("New Value");
        •  Get text of selected item in dropdown:
        • $('#<%=DropDownList.ClientID%> option:selected').text();
        •  Get Checkbox Status:
        • $('#<%=CheckBox.ClientID%>').attr('checked');
        •  Check the Checkbox:
        • $('#<%=CheckBox.ClientID%>').attr('checked',true);
        •  Uncheck the Checkbox:
        • $('#<%=CheckBox.ClientID%>').attr('checked',false);
        • Get Radiobutton Status:
        • $('#<%=RadioButton.ClientID%>').attr('checked');
        •  Check the RadioButton:
        • $('#<%=RadioButton.ClientID%>').attr('checked',true);
        •  Uncheck the RadioButton:
        • $('#<%=RadioButton.ClientID%>').attr('checked',false);
        •  Disable any control:
        • $('#<%=TextBox.ClientID%>').attr('disabled', true);
        •  Enable any control:
        • $('#<%=TextBox.ClientID%>').attr('disabled', false);
        •  Make textbox read only:
        • $('#<%=TextBox.ClientID%>').attr('readonly', 'readonly');

        • For getting the data you may also use as what I have said in previous blog, that is simpler

        Tuesday, 22 September 2015

        ORA:06413 Connection not Open


        • This blog is for those who want to connect Visual Studio with Oracle Database 10g or lower upto 9i.
        • I seen there are lots of problem while connecting the Visual Studio with the Oracle 10g and 9i.
        • I would like to share that Oracle has already left the support for the same & so as the patch for connection.
        • Then instead of using Oracle 10g or 9i client for connection with Oracle Server use the client for which Oracle Corporation use to give support. 
        • I had the same problem , all code and path variable were  checked and  were perfect. But then also Client was not connecting to oracle 10g Server.
        • Even though from SQL PLUS  it was connected. 
        • Thereafter I just uninstalled Oracle 10g client and installed Oracle 11g R2 32-bit and placed tns file in ADMIN folder of OracleHome. 
        • I checked once again from VS 2010 and VS 2012 and executed code. The server was connected. 

        For any query you may comment . Yours comments would be appreciated.

        Thursday, 10 September 2015

        Get the data from server controls using javascript in asp.net


        • Today I'll show you how to retrieve the server controls data easily using Javascript in ASP.NET.
        • Normally people I have seen use to retrieve the data from controls is using  something like this:
        function validate()
        {
             var text=document.getElementById('<%=TextBox1.ClientId%>').value;
           // do stuffs
        }

        • And then more code for if you want dropdownlist data and some other controls.
        • Instead simply one can use String function as (e.g. for DropDownList):

        function validate()
        {
             var text=String('<%=DropDownList1.SelectedItem.Text%>');
             var  value=String('<%=DropDownList1.SelectedItem.Value%>');
           // do stuffs
        }

        • That was for this blog have a great day. And yes any one having difficulty can comment anytime.

        How To Pass An Array As A Parameter While Calling an ASP.NET Web API C#

        Please visit my C# Corner Blog for this, where I have provided better efforts to make this concept more understandable - www.c-sharpcorner....