Posts

Showing posts from June, 2014

ASP.net - Safe method to check session is null

Robust application has to utilize Proper method to check the session veribles.Following  method is one of the best approch. Assume  Session["selmachine_id"] hold string value  string sessionMac = Session["selmachine_id"] as string;                 if (!string.IsNullOrEmpty(sessonTestId))                 {                     //Valid Action                  }

ASP.net best way to Return Multiple Values from a Function

From .NET Framework 4 Tuple class has been introduce to create combination of heterogeneous objects .Its can used to group different types of items (objects ) and indicate this group as single object. Tuple is a class and once you create the Tuple, you cannot change the types of the items or the values assigned in the creation. This makes the Tuple more like a struct. However this enable much safe way to return distinct number of    multiple elements to be returned for a function . Example function(return Boolean and string ) public class Class1     {  public static Tuple<Boolean, String> ExampleFunction(string parameterVal)         {   Boolean retunValue1= false;  string retunValue2 = ""; .......  return Tuple.Create(retunValue1, retunValue2 ); } } Calling Function and Retrieve return Values   var retTuple = Class1.ExampleFunction(parameterVal);    ...

Display hidden div in ASP.net page as a modal Dialog

In this approach you can load a content form the database (dynamic content) at the initial . page load to the div which going to display as a dialog  box when reqired .When it is not nessory to show you can hide it using CSS ( display :none). When the popup modal dialog is open ,the  content can be make visible by CSS In the below example I have generated a HTML table from code behind at the page load to the pop up div and display as a modal dialog.I have added dynamic feature (column filter) using jQuery. Using this approach you can avoid the performance delay of using separate .aspx page with i frame to load a dynamic content. aspx page ,,,div            <div  id="projectCreateDiv" style="width:500px ; display :none "  >                            <asp:Tabl...