Skip to main content

Posts

Showing posts from 2012

.NET Mathematics

Loading UserControl on another UserControl & assigning Properties of loaded UserControl Parent UserControl (.ascx) UI: <% @ Control Language ="C#" AutoEventWireup ="true" CodeBehind ="MultiVarientModule.ascx.cs"     Inherits ="Modules.MultiVarientModule" %> < div id ="parent" runat ="server"> </ div > Parent UserControl Code File (.cs) : #region CONSTANTS const string CAROUSAL = "~/Modules/Carousal.ascx" ; const string THREECOLUMNS = "~/Modules/ThreeColumn.ascx" ; const string REGULAR = "~/Modules/Regular.ascx" ; #endregion protected void Page_Load( object sender, EventArgs e) { switch (ControlName) {        case "Carousel" :               parent.Controls.Add(LoadControl(CAROUSAL));               break ;        case "ThreeColumn" :               parent.Controls.Add(LoadControl(THREECOLUMNS));               break ;        ca

Gridview Performance improvement with Custom Paging

Gridview provides excellent features to show the data on webpage. Few of the popular features are sorting, column arrangements, styles, item templates, editing, updating and deleting. Get the data from SQL, DataList, Arrays and bind the data to Gridview and it displays the data in required format. GridView1.DataSource = SQL command Result OR List() OR Array() GridView1.Databind(); When the data is huge and you bind the data with GridView, it can impact the performance of your page. To Overcome that, GridView Paging is provided but it fetches all the records and bind it to GridView and when you click on page number, it shows the records of that page index. GridView paging is also not good solution and hits the performance as it fetches all the records once and then bind it to GridView. Here is the solution which do custom paging and fetches the data when required. GridView with Custom Paging GridView is showing 10 records by default. Clicking on 'Nex

Wrap the data in Gridview

Sometime the data in Gridview column is large and it makes the scrollbar to appear on the page. Due to which User Interface of page get effected. Here are two solutions for achieving the required wrapping. Why two solution are provided? The reason is that sometime solution 1 doesn't work for all browser. It vary with the way how you are pulling the data in Gridview. Solution 1: Putting <ItemStyle> tag and setting the width of column. Wrapping the data using <ItemStyle> tag Solution 2: Putting <div> tag and styling on bounded column ( Works on all browsers ) Wrapping the data using <div> tag and styling Output:  Here is the output how data displayed in Gridview is wrapped. Gridview wrapping Keep posting your queries to get optimum solution.

System.BadImageFormatException

Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Data.SQLite' could not be loaded. System.BadImageFormatException: System.Data.SQLite

Sitecore Best Practices

Design Prospective: 1. Put components statically in html if it is being used multiple times and not much changes required. Use placeholders only to bind those components which are getting change frequently. 2. Always set presentation details on _standard values. 3. Do appropriate image resizing on server else it will slow down the performance when opening on browse. 4. Create template for providing data to presentation component. 5. Get the Data from DataSource from component Parameters to get variations. Code Prospective: 1. Test your html/css/javascript code in such a way that Page Editor is enable for edit by non technical staff. 2. Given meaningful names to placeholder so that right component could add under right placeholder. 3. Write code using C# coz this is language generally use by Sitecore Support team. Use GUID instead of path/name as content can be moved to some other location in content tree. 4. Create separate config file for your component instead of adding directly in w

Sitecore customization using pipelines

A pipeline consists of a number of processors arranged in sequence to process a common set of parameters. If I have a series of tasks, which need to be performed to accomplish a task, then a pipeline may be the way to go. Instead of passing to each processor an arguments object containing these parameters, the pipeline class itself exposes properties representing the parameters. Sitecore pipelines also allow an object to pass through each step. This object can be manipulated by any of the steps and passed through to the next step until the end is reached and the object can be used by whatever executed the pipeline in the first place. In configuration file, you will be able to see numbers of pipelines, which is default from sitecore. You can create your own custom code and add pipeline to execute that code. Example: Pipeline contains parameter ‘type’, which contains information about class and assembly as shown in snapshot. UI customization using pipelines Each step in pipeline is calle

Google Recaptcha implementation without plugin

Google Recaptcha Implementation STEP 1: Add Following Script on you page: < script type ="text/javascript" src ="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"> script > < script src ="http://code.jquery.com/jquery-latest.pack.js"> script > < script type ="text/javascript"> function showRecaptcha(element) { Recaptcha.create( "your_public_key" , element, { theme: "clean" , callback: Recaptcha.focus_response_field }); } function showResult() { //alert('start'); var challengeVal = Recaptcha.get_challenge(); //alert(challengeVal); var reponseVal = Recaptcha.get_response(); alert(reponseVal); var remoteIp = "172.18.224.92" ; //alert(remoteIp); var privateKey = ’Your_Private_Key’; var r