This blog is useful to all my friends who are working on the .Net Technology and wants to enhance their skills as well their problem solving ability.

Friday, August 28, 2015

uncaught typeerror cannot read property 'settings' of undefined jquery validate

I am getting error on line # 1069 where I write the below code and i'm done

 
if (!validator) return;
 
just need to write the above line in jquery.validator.js file line # 1069
 
Ref. Site

Clearing the credentials for connecting to a Team Foundation Server

i have one issue with team foundation server(TFS), I logged in with xyz and then I tried to login with abc, so again I required to login with xyz and I am getting stuck doing that ...

Ran in to a situation a couple of days ago where i needed to log into a Team Foundation Server as a different user - and since Visual Studio/Team Explorer "remembers" your last credentials you don't have a chance to re-enter these credentials.  This information is cached even after removing and re-adding the server in team explorer.  Which begs the question - where is it cached?

Turns out we are relying on Windows to do this for us.  To dump this cache all you need to do is go to control panel > User Accounts > Manage Your Network Passwords select the Team foundation Server and choose remove - viola! Next time you go into Team Explorer you will be prompted for a new set of credentials. 

And i'm done with my problem ....

Ref. site
http://blogs.msdn.com/b/visualstudioalm/archive/2012/08/29/clearing-the-credentials-for-connecting-to-a-team-foundation-server.aspx
 

Thursday, August 27, 2015

mvc / mvc 5 bootstrap-paginator customized pagination

@{
    Layout = null;
}



    $(function () {
        var options = {
            totalPages: '@ViewBag.TotalPages',
            size: 'large',
            alignment: 'right',
            onPageClicked: function (e, originalEvent, type, page) {
                ObjParams.pageNumber = page;
                ;
                $.ajax({
                    url: '@Url.Action(null)',
                    type: 'POST',
                    dataType: 'json',
                    data: ObjParams,
                    success: function (response) {
                        ;
                        $("#divContainer").html('');
                        $("#divContainer").empty();
                        $("#divContainer").html(response.DataContent.Content);
                    },
                    error: function (response) {
                    }
                })
            }
        }
        $('#paginator-test').bootstrapPaginator(options);
    });

Wednesday, June 17, 2015

c#.net mathematical expression string to calculation

c#.net mathematical expression string to calculation
If you want to evaluate a string expression use the below code snippet.
using System.Data;

DataTable dt = new DataTable();
var v = dt.Compute("3 * (2+4)","");

Friday, August 29, 2014

SQL Dependency with Cache (server side) For MVC and ASP.NET

Step 1 :

ALTER DATABASE [XYZ] SET ENABLE_BROKER with rollback immediate;
ALTER DATABASE [XYZ] SET TRUSTWORTHY ON;

Step 2 :


   
     
       
         
       

     

   


Step 3 :

public DataSet GetReaderByCmdCaching(string command, int keyID)
        {
            object classlock = new object();
            this.GetConnection();
            System.Data.DataSet returnValue = new DataSet();
            string strKey = "readerdata" + keyID;
            string strKeyNavigation = "readerdatanavigation" + keyID;
            if (HttpContext.Current.Cache[strKey] == null)
            {
                lock (classlock)
                {
                    System.Data.SqlClient.SqlDependency.Start(this.connectionString);
                    this.sqlCommand.CommandText = command;
                    SqlCacheDependency dependency = new SqlCacheDependency("CacheDatabaseConnection", "TableName");
                    SqlDataAdapter da = new SqlDataAdapter(this.sqlCommand);
                    da.Fill(returnValue);
                    HttpContext.Current.Cache.Insert(strKey, returnValue, dependency);
                }
            }
            else
            {
                returnValue = (System.Data.DataSet)HttpContext.Current.Cache[strKey];
            }
           
            return returnValue;
        }

Step 4 :

DataSet dsTemp = GetReaderByCmdCaching("Name of SP or Query", UniqueID);

Step 5 :

You are done, whenever any data change in Table it generate the Cache :) Happy Coding.

Tuesday, August 26, 2014

Sql Server Email Validation in Store procedure

IF not (

CHARINDEX(' ',LTRIM(RTRIM(@email))) = 0

AND LEFT(LTRIM(@email),1) <> '@'

AND RIGHT(RTRIM(@email),1) <> '.'

AND CHARINDEX('.',@email ,CHARINDEX('@',@email)) - CHARINDEX('@',@email ) > 1

AND LEN(LTRIM(RTRIM(@email ))) - LEN(REPLACE(LTRIM(RTRIM(@email)),'@','')) = 1

AND CHARINDEX('.',REVERSE(LTRIM(RTRIM(@email)))) >= 3

AND (CHARINDEX('.@',@email ) = 0 AND CHARINDEX('..',@email ) = 0)

)

begin

   // TO DO

end

Friday, August 22, 2014

custom paging using store procedure in sql server with row number

input parameter for sp

, @PageSize INT = 10

, @PageIndex INT = 1

store procedure definitions

SELECT XYZID, XYZType, InCylinder,InSystem,XXXX
FROM (
SELECT XYZes.XYZID
 , XYZes.XYZType
 , ISNULL((SELECT SUM(TABLEPQR.XYZVolume) FROM TABLEPQR WHERE TABLEPQR.XYZID = XYZes.XYZID AND TABLEPQR.AssetTypeID IN (1, 3) ), 0) AS InCylinder
 , ISNULL((SELECT SUM(TABLEPQR.XYZVolume) FROM TABLEPQR WHERE TABLEPQR.XYZID = XYZes.XYZID AND TABLEPQR.AssetTypeID = 2 ), 0) AS InSystem
 , ISNULL(
  ISNULL((SELECT SUM(TABLEXYZ.XYZVolume) FROM TABLEXYZ WHERE TABLEXYZ.XYZTypeID = XYZes.XYZID AND TABLEXYZ.Activity = 'XXXX'), 0)
  +
  ISNULL((SELECT SUM(TABLENNN.XYZVolume) FROM TABLENNN WHERE TABLENNN.XYZTypeID = XYZes.XYZID AND TABLENNN.Activity = 'XXXX'), 0)
  , 0) AS XXXX,
ROW_NUMBER() OVER (ORDER BY XYZID) AS RowNum
FROM XYZes ) AS SOD
WHERE SOD.RowNum BETWEEN ((@PageIndex-1)*@PageSize)+1
AND @PageSize*(@PageIndex)

select @RecordCount = COUNT(*) From XYZes
return @RecordCount