Wednesday, July 16, 2014

Bootstrap 3 responsive not working on mobile

I was working on one eCommerce system and it was bootstrapped ... But somehow It was not working as responsive in mobile browsers but it was showing responsive nature in normal browser...

I was missing following line in header section

<meta name="viewport" content="width=device-width, 
initial-scale=1, maximum-scale=1">
 
 
And now it started working 
Submit this story to DotNetKicks

Read more...

Friday, April 4, 2014

301 redirect using web.config

To do 301 permanent redirect add following line of codes in web.config.


<configuration>
<system .webserver>
 <rewrite>
      <rules>
        <rule name="Redirect domain.com to www" patternsyntax="Wildcard" stopprocessing="true">
          <match url="*">
          <conditions>
            <add input="{HTTP_HOST}" pattern="yourdomain.com">
          </add></conditions>
          <action type="Redirect" url="http://www.yourdomain.com/{R:0}">
        </action></match></rule>
      </rules>
    </rewrite>
</system .webserver>
</configuration>
Submit this story to DotNetKicks

Read more...

Saturday, January 18, 2014

How do I enable HTTP PUT and DELETE for ASP.NET MVC

  1. GO to Handler Mappings in your IIS Manager. 
  2. Find ExtensionlessUrlHandler-Integrated-4.0, 
  3. double click it. 
  4. Click Request Restrictions... button and on Verbs tab, add both DELETE and PUT. 


Remove WebDav from "Modules" and from "Handler Mappings"


Modules:
                WebDAVModule, %windir%\System32\inetsrv\webdav.dll, Native, Inherited

Handler Mappings:

                WebDAV, *, Enabled, Unspecified, WebDAVModule, Inherited

Then Restart IIS

It results in a Web.Config change of:

  <system.webServer>
        <modules>
            <remove name="WebDAVModule" />
        </modules>
        <handlers>
            <remove name="WebDAV" />
        </handlers>
  </system.webServer>

 
Submit this story to DotNetKicks

Read more...

Sunday, November 3, 2013

What is Affiliate Marketing - How to make Money Online

Every day more and more people are looking for different ways to earn extra money, or to earn a living, both in the online and offline worlds people are starting realize that having a "job" and working 40 hours a week for 40 years is not the ideal way to live. And it is true working like an animal make no sense anymore when there are many opportunities available to make money online.There are many ways to go for Extra money, but in case of online work You can Work from Home and Make Money online through Internet Jobs or By doing Affiliate Marketing.

Affiliate marketing is a type of performance-based marketing in which a business rewards one or more affiliates for each visitor or customer brought by the affiliate's own marketing efforts. 

As we have some blog or web site with good number of Visitors we can make decent amount of money using Affiliate Marketing.Your affiliate can be anything from a website or e-newsletter or blog or squidoo lense or facebook page anything which can be shared with people online, it could also be a shopping portal, to name a few. Many online websites and shopping portals uses Affiliate program, where they allow any one to do advertising online using Affiliated link, and the company pays the affiliate a 5%-20% commission on sales. 

 


Viral Marketing: is a Marketing phenomenon that facilitates and encourages people to pass along a marketing message. Viral Marketing basically uses replication of some product or brand with use of  either Images, Videos, text ads and continuously making people aware about the product or brand.
One of the Effective way to reach many people is Viral Marketing. Funny Videos, Funny images, relative content or publishing interesting article are ways for Viral Marketing, making more and more people aware about the Brand.


Submit this story to DotNetKicks

Read more...

Sunday, October 20, 2013

getting basic data types using reflection than nullable

While using class properties to use for data base connectivity, i.e. LINQ TO SQL, I was facing issue for nullable types. I was using Reflection to fetch property type names, but for NULLABLE properties it use to send me property type name as NULLABLE`1. I was suppose to use following switch case (Determine Nullable properties via reflection)
public static string getJSType(PropertyInfo propertyinfo)
        {

//GetCoreType function returns Property type.
switch (GetCoreType(propertyinfo.PropertyType).Name.ToUpper())
                {
                    case "INT16":
                        return "number";
                    case "UINT16":
                        return "number";
                    case "SHORT":
                        return "number";
                    case "USHORT":
                        return "number";
                    case "INT32":
                        return "number";
                    case "UINT32":
                        return "number";
                    case "INT":
                        return "number";
                    case "UINT":
                        return "number";
                    case "INT64":
                        return "longnumber";
                    case "UINT64":
                        return "longnumber";
                    case "LONG":
                        return "longnumber";
                    case "ULONG":
                        return "longnumber";
                    case "DECIMAL":
                        return "decimal";
                    case "DOUBLE":
                        return "float";
                    case "BIGINT":
                        return "longnumber";
                    case "STRING":
                        return "text";
                    case "DATETIME":
                        return "datepicker";
                    case "BOOLEAN":
                        return "flag";
                }
            //}
            return "text";
        }
To determine type of NULLABLE properties via reflection, I used following function GetCoreType
 private Type GetCoreType(Type type)
        {
            if (type.IsGenericType &&
                type.GetGenericTypeDefinition() == typeof(Nullable<>))
                return Nullable.GetUnderlyingType(type);
            else
                return type;
        }
Find Type of Nullable Properties via Reflection. Determine type of Nullable properties view Relection. While using reflection get core property type of nullable properties.
Submit this story to DotNetKicks

Read more...

Saturday, September 21, 2013

Remove Double Quotes From String

To Strip double Quotes from string use following code

Lets say s is out string
string newstr = string.Empty
s = s.Replace("""", "");
OR
string newstr = string.Empty
s = s.Replace("\"", "");

Submit this story to DotNetKicks

Read more...

Wednesday, May 22, 2013

Hide Unncessary space when Validator messages are not firing....

While working on validator controls, we need to give some text message to display. When we give a text message many times space is getting created to show validator message....

When validators are not firing that time this space doesn't look good....

To hide this unnecessary space when validator message is not firing set

Display property to Dynamic

i.e. Display="dynamic"

Submit this story to DotNetKicks

Read more...

Saturday, April 6, 2013

Its All About Afilioplace.com place to buy and sell web designs(landing pages)

Afilioplace is the best place to boost Affiliate marketing campaigns.  It the place where Affiliates can buy and sell all the resources required for Successful Affiliate Marketing. This is the best Affiliate Marketplace This site provides quality tools for those who want to be successful in affiliate marketing no matter who they are, they can be simple affiliate marketers, writers, web designers or some programmer.. No matter who you are Afilioplace is the one site which will enhance your marketing campaings...

This site has many things to offer, we can MAKE MONEY WITH AFILIOPLACE...
  1. Designer can sell landing pages for Affiliate purpose
  2. Writers can sell pages, ebooks
  3. Programmers can sell softwares
  4. Marketers can sell their ideas....
Whatever sale this site makes we earn 70% of it which is actually a Really good marketing strategy, we can use this platform to make decent amount of money as well as we can sell our ideas and our own work...

Submit this story to DotNetKicks

Read more...

Wednesday, February 13, 2013

specified cast is not valid. asp.net checkbox

While working on Grid view with Checkboxes and binding dynamic data, I came across an Erroe saying "Specified Cast is Not Valid", it was related to following code
  
                    
                

Then after doing search for specified cast is not valid. asp.net checkbox, I made following changes in the same code it worked.
 
                    
                
I am not going into More details for specified cast is not valid for asp.net checkbox in this article. Submit this story to DotNetKicks

Read more...

Monday, February 4, 2013

The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. Solved...

While working with Asp.NET and Membership, using MS SQL 2008 R2 I came across following error. My web application was working perfect on my local machine but when I hosted it on remote server I got following error.
The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.
After R&D I had came across three possible solutions "WHICH I THINK ARE RIGHT, AS THEY WORKED FOR ME IN DIFFERENT SCENARIOS."

  1. Check "aspnet_SchemaVersions" table in database and make sure CompatibleSchemaVersion is set to "1" for all the Features (e.g. common, membership, role manager etc) available in table. Also make sure IsCurrentVersion column values are set to 'True" for all Features.
  2. In Web.Config, and aspnet_Applications table check if application Name is matching or not. Application name in web.config's Membership>Providers, Profile>Providers, RoleManager>Providers are matching with application name in database.
  3. In Membership>Provider I had "AspNetSqlMembershipProvider" type as type="System.Web.Security.SqlMembershipProvider" which I modified (after referring to some articles online) to type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Application worked for me when I checked all these things and made changes in my application.
Submit this story to DotNetKicks

Read more...

Friday, January 18, 2013

Cannot connect to local SQL Server Express 2008 R2

Some times while using SQL server R2 on local machines we get a connection error something looking like


TITLE: Connect to Server
Cannot connect to (local).
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)

To deal with it, there are two things we need to check
  1. Try this as your server: .\SQLEXPRESS
  2. This error occurs if SQLEXPRESS instance is not started. To verify the service is started or not run services.msc and look for  "SQL Server (SQLEXPRESS)" service, status should be "Started", if it is not, try to start it manually.
Submit this story to DotNetKicks

Read more...

Wednesday, January 9, 2013

ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized

ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized

While using transaction in Asp.net/C# I got above error.

To solve this error I simply added Transaction object in SqlCommand like below
SqlTransaction Transaction;
conn.Open();
Transaction = conn.BeginTransaction(); 
SqlCommand cmd = new SqlCommand(sql, conn, Transaction);

Submit this story to DotNetKicks

Read more...

Sunday, November 11, 2012

Fetch Distinct Values From Datatable In c#

To Fetch distinct values from already fetched DataTable in Ado.net we can use following method.

DataTable temp = DT.DefaultView.ToTable(true, "ContractId");
//Note here I wanted to fetch Distinct ContractIds from DT
Use Above code to select Distinct values from the Datatable, or Use Above code to fetch distinct values from Ado.Net Datatable or datatable in c#. Submit this story to DotNetKicks

Read more...

Monday, October 29, 2012

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException

While working on Asp.Net application with Master Pages, Child pages and web user controls getting following error is very common. Which is related to Events related to Web user controls, e.g. Button click event...

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument.  Event validation is enabled using  in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

In such cases as error says we simply have to disable EventValidation in @Page directive and error disappears.

<%@ Page EnableEventValidation="false" %>
OR enable it for whole application by modifying it in web.config file

<%@pages enableeventvalidation="false">
<%@/pages>
Submit this story to DotNetKicks

Read more...

Thursday, August 9, 2012

Auto Generate Serial Number in GridView

To auto generate serial number in Gridview, which we can use only for display purpose and has nothing to do with database and data related operations.

  • Add Following Column in Grid View at first position

       
       <%# ((GridViewRow)Container).RowIndex + 1%>
   
 

Above code will simply autogenerate serial number in Gridview
Submit this story to DotNetKicks

Read more...

Wednesday, August 1, 2012

Textbox with background image using CSS

We can use CSS To make stylish textboxes like rounded corner textbox or textbox with some image inside. Rounded corner text box is like following image.


To make rounded corner textbox we use following logic. We will put textbox in some wrapper layer i.e. div tag and apply style to wrapper layer.
Now style applied to wrapper div tag is as follows
.tt-wrapper
 {
 background-image:url('images/user_box.png');
 margin:0;
 width:255px;
 height:35px; 
  }
In above style user_box.png is a background image (check following image.)


 Then we apply style to fit the textbox with in wrapper div class.
.tt{
 width:240px;
 height:25px;
 margin:5px 0 0 8px;
 border:none;
 background:none;
 }
And we are done with Textbox with rounded corner. To display some image inside textbox we simply need to add background image in the class applied to textbox
Submit this story to DotNetKicks

Read more...

Install CSI files BlackBerry

I am using PhoneGap.com for BlackBerry development, after developing web app I came across a situation where I had to register my code signing key using  SignatureTool.jar, I used following line of code in Command prompt to register my key and password pair. C:\BBWP\bin>SignatureTool.jar client-RBB-YOURCSICODE.csi c:\BBWP\bin>SignatureTool.jar client-RCR-  YOURCSICODE.csi c:\BBWP\bin>SignatureTool.jar client-RRT-  YOURCSICODE.csi If you don't have a private key installed you need to create one. And use the pin number which you used during the registration process.
Submit this story to DotNetKicks

Read more...

Javascript Find Arguments Passed to a Function

While working on Javascript optimization we can always use some functions having variable number of arguments.
E.g. if we come across a situation where we have to use one function to toggle visibility of the objects, but depending on clients input number of objects which needs to hide/show varies. In this case we can write a function as below where number of parameters can any variable.
//Assumption 0th parameter is boolean 

 function toggle() {
        var args = toggle.arguments
        for (v = 1; v < args.length; v++) {
            obj = window.document.getElementById(args[v]);
            if (args[0]) obj.style.display = "";
            else obj.style.display = "none";
        }
    }
We can use this type of functions to minimize size of javascript before optimizing it.
Submit this story to DotNetKicks

Read more...

Logout User In Asp.net Membership

While developing usermanagement based web application using Membership provider, many times we come across some trivial issues or queries as follows
  • formsauthentication.signout not working
  • Using formsauthentication.signout
  • logout user programmatically
  • Check user date subscription and log out if user is not valid.
  • programmatically logout in asp net
  • Logout user in asp.net Membership
Solution for all above queries is as follows
FormsAuthentication.SignOut();
  Session.Abandon();

 // clear authentication cookie
 HttpCookie frmcookie = new HttpCookie(FormsAuthentication.FormsCookieName, "");
 frmcookie.Expires = DateTime.Now.AddYears(-1);
 Response.Cookies.Add(frmcookie);

 // clear session cookie if we use any
 HttpCookie sessioncookie = new HttpCookie("ASP.NET_SessionId", "");
 sessioncookie.Expires = DateTime.Now.AddYears(-1);
 Response.Cookies.Add(sessioncookie);

 FormsAuthentication.RedirectToLoginPage("v=SubscriptionExpired");
Above code signout the user, remove all the Cookies set. Forms Authentication.RedirectToLoginPage uses settings in web.config file. We can pass Querystring to the function so that we can show proper Messages.
Submit this story to DotNetKicks

Read more...

Display rupee symbol website

To display Rupee Symbol to website use following code.
Ruppee Symbol

  1. Add a stylesheet link in the head section of your webpage:


  • Add the following code enclosing your "Rs."
    Rs. 1000
    
  • OR Just include the following javascript and it will update all the "Rs" / "Rs." for you
    
    
    This is how we can display indian rupee symbol in website/blog. If Unicode is supported then we can use rupee symbol positioned at U+20B9.
    Submit this story to DotNetKicks

    Read more...