Monday, 18 December 2017

.net developer

I ordered food from this place yesterday. The delivery was on time and the delivery boy was gentle at his work. I had their veg Cheese grilled sandwich. The burger was very huge and you can't eat anything more after eating this burger. It tasted like a good desi burger with soft buns. It was very filling.
Sankalp south Indian Menu, Reviews, Photos, Location and Info - Food Park

RJ 14 food for mansarovar Jaipur

I ordered food from this place yesterday. The delivery was on time and the delivery boy was gentle at his work. I had their veg Cheese grilled sandwich. The burger was very huge and you can't eat anything more after eating this burger. It tasted like a good desi burger with soft buns. It was very filling.

RJ 14 Menu, Reviews, Photos, Location and Info - Food Park

Thursday, 31 August 2017

Cafe By The Way food for mansarovar Jaipur

I ordered food from this place yesterday. The delivery was on time and the delivery boy was gentle at his work. I had their veg Cheese grilled sandwich. The burger was very huge and you can't eat anything more after eating this burger. It tasted like a good desi burger with soft buns. It was very filling.
Cafe By The Way Menu, Reviews, Photos, Location and Info - Zomato

Sunday, 9 October 2016

Read html from a Url

To read html from a url, you have to make HttpWebRequest.

First make HttpWebRequest and add url in it.


      HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("http://www.yourdomain.com/filename-1.html");      


Now Specify timeout and UserAgent

      httpRequest.Timeout = 10000;     // 10 secs
      httpRequest.UserAgent = "Code Sample Web Client";


Now get a response in HttpWebResponse and from HttpWebResponse you will get your html.

      HttpWebResponse webResponse = (HttpWebResponse)httpRequest.GetResponse();
      StreamReader responseStream = new StreamReader(webResponse.GetResponseStream());

      string FileMatter = responseStream.ReadToEnd();

In FileMatter variable you will get all html from given url.



Code
             HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create("http://www.yourdomain.com/filename-1.html");  

            httpRequest.Timeout = 10000;     // 10 secs
            httpRequest.UserAgent = "Code Sample Web Client";

            HttpWebResponse webResponse = (HttpWebResponse)httpRequest.GetResponse();
            StreamReader responseStream = new StreamReader(webResponse.GetResponseStream());

            string FileMatter = responseStream.ReadToEnd();

Read html file from project folder

To read html from a file, first create a html file with some html in your project.






Write following code to read contents of a html file.



      System.IO.File.ReadAllText("http://www.yourdomain.com/3c-report-details.html");


Thursday, 6 October 2016

Dhoni greatest innings vs pakistan


Keyword not supported: initial catalog

Introduction

In this In this article I will explain cause and resolution of Keyword not supported: initial catalog error

Cause

This error occurs when we are implement asp.net membership and error occurs in Global.asax file at the following line:
   WebSecurity.InitializeDatabaseConnection("Action", "Member", "MemberId", "Email", autoCreateTables:= True)
This error occurs when we have not specified provider name in connectionString.

Resolution

To resolve this error you need check your connectionString and add providername property in your connectionString.

Suppose you are trying to connect with Sql Server so you have to add providerName="System.Data.SqlClient"

Example

     <connectionStrings>
   <add name="con" connectionString="Data Source=ServerName;Initial Catalog=master;Integrated Security=SSPI;" providerName="System.Data.SqlClient"></add>
  </connectionStrings>

Tuesday, 17 June 2014

Add Html5 Tags in Internet Explorer 8

Introduction:

Html5 is popular language but some of older browser such as IE8,IE7 and lower not supported Html5.

Html5 introduce some new elements such as header,section but older browser doesn't know about these tags then it can't generate them so you will find that in IE8 or lower your website will be without any styles.

Here is solution for add Html5 tags in IE8 and lower.

First we have to detect IE Version and then we have to create elements which is added by Html5.

Code:


var userAgent = navigator.userAgent.toLowerCase();
// Test if the browser is IE and check the version number is lower than 9
if (/msie/.test(userAgent) && 
    parseFloat((userAgent.match(/.*(?:rv|ie)[\/: ](.+?)([ \);]|$)/) || [])[1]) < 9) {
 
         document.createElement('header');
         document.createElement('section');
         document.createElement('article');
         document.createElement('aside');
         document.createElement('nav');
         document.createElement('footer');
}


Copy the following code at top of page.

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->



Detect mobile device using JavaScript

Introduction:

Here i will explain how to detect mobile device using JavaScript

This is simplest way to detect mobile device.

Code:

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
 // some code..
}


Friday, 25 April 2014

Remove HTML tags from string but keep content.

Introduction:

Here I will explain how to remove specific HTML tag from string but keep content which is inside tag.

In JQuery we can remove element by remove()  function but how would we remove specific HTML tag from string.

Just need to use unwrap() function of JQuery.

Code:
$('p').contents().unwrap();



Example:






Suppose we want to remove all p page from string.

var temp='<div>Some text</div><p style="color:red">More text<span>here</span></p><p>Even more</p>';

var StrTemp=$(temp).find('p').contents().unwrap();

alert(StrTemp);



This will alert "<div>Some text</div>More text<span>here</span>Even more"
unwrap functino remove all p tag from string.



Monday, 31 March 2014

JQuery Check element is block or hidden.

Introduction:

Here I will explain how to check any element like div,p,input is block or hidden.

In JQuery we can show/hide element by show(), hide() functions but how would we test element is visible or not so here is solution for check visibility of element.

Just need to check visible property.

Code:
$(element).is(":visible");


Example:





Suppose you want to check visibility of div element then just select div.

var b = $('div.test').is(":visible");;
alert(b);


This will alert true if div with class test is visible and return false if div with class test is hidden.



JavaScript get query string values

Introduction:

Here I will explain how to get Query String value from URL in JavaScript.

Code:
function getParameterByName(name) {
 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
 results = regex.exec(location.search);
 return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}


Example:





Suppose you have three Query String in current URL a b and c and you need value of b so just need to pass b in this function.

var b = getParameterByName('b');
alert(b);

This will alert value of b.



Monday, 24 March 2014

Change Default Port Number in Visual Studio 2012

Step 1
Right Click on the web site or project node in Solution Explorer.

Step 2
Select properties from options.



Step 3
Choose Web option.

Step 4
Choose Use Visual Studio Development Server Radio button.

Step 5
And Then Choose Specific Port, Now a Text Box is enable and you can set port number to whatever you need.





Thursday, 2 January 2014

MVC 4 New Feature add Controller to other project folder.

In Mvc 3, controller class can be added only in the "Controllers" folder ,adding controller class to other folder is not allowed but in Mvc 4, we can add controller class to other folder.

Step 1: Create a "Data" folder inside "Controllers" folder.

Step 2: Add Controller inside Data folder.




Wednesday, 1 January 2014

Implement Simple Membership , Creating Role & Register admin account With Simple Membership MVC 4

For Creating Role,Login,Registration first we have to Initialize simple membership.
For implement simple membership follow 2 easy steps.

Step 1: Initialize membership in Global.asax file. Copy this function in Global.asax
void initializeMembership()
        {
            if (!WebSecurity.Initialized)
                WebSecurity.InitializeDatabaseConnection("ConnectionString", "UserProfile", "UserId", "UserName", autoCreateTables: true);

        }
And Call this function in Application_Start().
This function create Simple Membership tables in given "ConnectionString" and initialize membership.

Step 2: Add settings in web config.
<profile defaultProvider="SimpleProfileProvider">
      <providers>
        <add name="SimpleProfileProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" 
             connectionStringName="ConnectionString" applicationName="/" />
      </providers>
    </profile>
    <membership defaultProvider="SimpleMembershipProvider">
      <providers>
        <add name="SimpleMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" />
      </providers>
    </membership>
    <roleManager defaultProvider="SimpleRoleProvider">
      <providers>
        <add name="SimpleRoleProvider" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData" />
      </providers>
    </roleManager>
Now your simple membership tables are created and simple membership is Initialized.

Creating Role


For Creating Role we use System.Web.Security.Roles Namespace
var role = System.Web.Security.Roles.Provider;
            if (!role.RoleExists("Admin"))
            {
                role.CreateRole("Admin");
            }

Register Admin Account


For Register Admin we use WebMatrix.WebData.WebSecurity namespace
  WebSecurity.CreateUserAndAccount("Admin", "admin123");
add this user to admin role.
   role.AddUsersToRoles(new[] { "Admin" }, new[] { "Admin" });
First Parameter usernames and second roles.


Thursday, 12 September 2013

Create a endsWith Function in JavaScript.

Javascript does not have a endsWith function so we have to create it manually we use String prototype for create endsWith function.
if (typeof String.prototype.endsWith !== 'function') {
    String.prototype.endsWith = function(suffix) {
        return this.indexOf(suffix, this.length - suffix.length) !== -1;
    };
}
Then you can use it directly on string values.
var data = "Lorem ipsum dolor sit amet";
data.endsWith('amet'); //true



Create a Startwith Function in JavaScript.

Javascript does not have a StartsWith function so we have to create it manually we use String prototype for create StartsWith function.
if (typeof String.prototype.startsWith != 'function') {
  // see below for better implementation!
  String.prototype.startsWith = function (str){
    return this.indexOf(str) == 0;
  };
}
Then you can use it directly on string values.
"Hello World!".startsWith("He"); // true

var data = "Hello world";
var input = 'He';
data.startsWith(input); // true




Thursday, 25 April 2013

Get Facebook Comments details by ajax request.

      var url = "http://getpaidtomeme.com/image.aspx?imagenum=15195";
      $.ajax({
            url: "https://graph.facebook.com/comments/?ids="+url+"",
            dataType: "jsonp",
            success: function (data) {
                 alert(JSON.stringify(data));
            },
            error: function (data) {
                consol.log(data);
            }
     });

Just change url here.

Live Demo



Get tweet and user detail from twitter API using JQuery

var username = "ankushjain99";
$.ajax({
            url: "https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name="+username+"&count=20",
            dataType: "jsonp",
            success: function (data) {
                 alert(JSON.stringify(data));
            },
            error: function (data) {
                consol.log(data);
            }
});

Just Change username

Live Demo



Use Google Currency Converter API in JQuery

        function buildQuery(amount, from, to) {
            var str = "http://www.google.com/ig/calculator?hl=en&q=" + amount + "" + from + "%3D%3F" + to + "";
            return "select * from json where url ='" + str + "' ";
        }

        $.ajax({
            url: 'http://query.yahooapis.com/v1/public/yql',
            data: {
                q: buildQuery("100","KWD","INR"),
                format: "json"
            },
            dataType: "jsonp",
            success: function (data) {
                alert(data.query.results.json.lhs + "=" + data.query.results.json.rhs);
            },
            error: function (data) {
                consol.log(data);
            }
      });
Just change buildQuery("100","KWD","INR") parameters.

Live Demo