Skip to main content

Posts

Showing posts from February, 2013

Custom Treeview

Custom Treeview control useful when multilevel hierarchical data need to be displayed and setting default can go at any level and providing access to each level then this can be the right choice. Check the below link for the complete details on its usage and source code. http://www.codeproject.com/Tips/548924/Custom-Treeview

Find changeset details with changeset id in TFS

I want to know change set details and the only thing I know is change set id, are you in this situation without knowing how to? Find solution below coz I was is in this same state before few days and found the solution in one of the web site :). Open team explorer > source control explorer > Set the focus on Source Control Explorer in Visual studio and press CTRL+G Below window will pop up, give the change set id in it and then details will be shown in next window.

Currency formatting in C#

string .Format( "{0:c}" , 102); Using the above code will return a result like $102.00. Since by default $ sign comes and if you want to change the symbol to other like pound or sterling change the culture info details as the below code sample. string .Format( new CultureInfo ( "en-US" ), "{0:c}" , 102); // This code again gives $ symbol since I have used “en-US” ;). Please check the sample language codes below to use the symbol you require the complete list of language code is available in this url “http://msdn.microsoft.com/en-us/library/ms533052(v=vs.85).aspx”. en-us English (United States) en-gb English (United Kingdom) en-au English (Australia) en-ca English (Canada) en-nz English (New Zealand) en-ie English (Ireland) en-za English (South Africa) en-jm English (Jamaica) en English (Caribbean) en-bz English (Belize) ...

To make the event args empty to avoid the same call on next postback

I faced an issue like, I raised a postback manually through javascript for downloading a report but once it is done on every click on other controls that raises postback wasn't working properly. I got confused and browsed for sometimes to find reason of this issue. In the late evening I found solution that Event attributes should be reseted to escape from this prob. But still am searching for the reasons. Project: .Net Application Solution: theForm.__EVENTTARGET.value = "" ; theForm.__EVENTARGUMENT.value = "" ; Though it was simple fix it made me MAD for few hours  O.o 

Exception handling in stored procedure

Exception handling in stored procedure for logging and continues running of the sp even after a error. CREATE PROCEDURE  @TypeData AS [DataTable] READONLY          AS                     BEGIN         SET NOCOUNT ON;          SELECT IDENTITY(INT, 1, 1) AS RowIndex, ...  INTO #TempDataTable FROM @TypeData        --Temp table to log exceptions  CREATE TABLE #TempException(ExceptionMessage VARCHAR(2000));     DECLARE @MaxRow INT,  @RowID INT      --Set maxrow and rowid  SET @MaxRow = (SELECT ISNULL(COUNT(1), 0) FROM # TempDataTable )         SET @RowID = 1                 WHILE @RowID <= @MaxRow         BEGIN               --your logic...

How to pass datatable as in parameter to stored procedure

This is one of the issue I came across while developing a window service for updating data in bulk. But this was developed with the complete support my friends and all the credits goes to them ;). Stored Procedure CREATE PROCEDURE  MySP        @TypeDataTable  AS [ MyType ] READONLY          AS                      BEGIN //Your logic END User defined Type   CREATE TYPE  MyType  AS TABLE (           [Column] [DataType] NULL/NOT NULL,           ... ) From code call the same we usually call the stored procs by passing the DataTable object as paramater.

Expand/Collapse extender using javascript

//Function to expand a particular section function ExpandOnly(behId) {     var   listOfBehID =[ ];     for ( var i = 0; i <  listOfBehID .length; i++) {         var objCollapser = $find( listOfBehID [i]);         if (behId.toLowerCase() ==  listOfBehID [i].toLowerCase()) {             objCollapser._doOpen();//to expand         }         else {             objCollapser._doClose();//to collapse         }     } }

Some useful js methods

/**   *   remove url from browser address bar without page refresh / works only with html5 enabled browser it seems   */     var uri = window.location.toString();     if (uri.indexOf("?") > 0) {         var clean_uri = uri.substring(0, uri.indexOf("?"));         window.history.replaceState({} , document.title, clean_uri);     } /**   * To convert utc to est   */ function convertUTCtoEST(utcDate) { var offsetValue = 5;        var dateTime ="";        try{               if(utcDate != undefined && utcDate != null && Trim(utcDate).length > 0){                      var estDate = new Date(utcDate);  ...

IE6 Fix - Modal popup extender

To avoid dropdowns and iframes shown above modal pop up JS function pageLoad() {   var bid = [ ];  jQuery.each(bid, function () {    try {     var val = this ;    modalbehavior = $find( this );     //Add the functions to handle the ModalPopupExtender's 'Shown'/'Hidden' event.     modalbehavior.add_shown(mpeShown);    modalbehavior.add_hiding(mpeHidden);   } catch (err) {  //do nothing  }  }); } function   mpeShown () {             //If the browser is IE6, add a iframe into the modal panel.             document.documentElement.style.overflow = 'hidden' ;      if (Sys.Browser.name == "Microsoft Internet Explorer" && Sys.Browser.version < 7) {           ...

Ajax call in Asp.net

Different ways of Ajax call in Asp.net PageMethods: function CallMe(status) {   // call server side method   PageMethods."Method name"(parameters,  CallOnSuccess ,  CallOnFailure ); } // Calls the popup on successfull completion function  CallOnSuccess (res) { } // alert message on some failure function   CallOnFailure  (res, destCtrl) { } Jquery: function GetColumnList() {             jQuery.ajax({                 url: Page/ CallBack ' ,                 type: "POST" ,                 data: "{ }" ,                 contentType: "application/json; charse...