Skip to main content


Showing posts from September, 2012

How to call server side function from client side javascript in ASP.Net?

How to call serverside function from client side javascript in ASP.Net?
Call ASP.Net/C# function using Javscript Usually in platform, server side functions (all codes written in,C#) are executing from the server side and all client side funtions (javascript,jquery,ajax) are executing from the client side. Obviously client side functions are too faster than the server side because there is no need to go upto server, will running from the browser itself. But we are unable to written all functions in client side to get good performance. But for this technique, there is some tips can be used. What we are going to do is, we are writing a server side code in ASP.Net,C# and call these functions from client side using javascript and ajax. Steps to Calling ServerSide method from javscript Create a aspx page with three textboxes and a button control.User enter two numbers in first two textboxes and press calculate button.We are fetching entered values and calling a serverside funt…

How to maintain scroll position after post back?

How to maintain scroll position in ASP.Net Pages When web pages are posted back to the server, by default user is returned to the top of the page. On a large web page, you might have a requirement to scroll down the user automatically to the last position on the page. MaintainScrollPositionOnPostBack page property can be used to achieve this  in one of the following ways. Application level:To set the property by default for all pages in the website, open web.config and add the attribute to the pages node.<pages maintainScrollPositionOnPostBack=”true”>Page Level:for a particular page, open the aspx and set the property<%@ Page MaintainScrollPositionOnPostback=”true” …Code level: to set the property programmaticallyPage.MaintainScrollPositionOnPostBack = true;Reference :

Add Web Part Programatically on Home / Default Page


Create a SharePoint 2010 Solution in Visual Studio.Add Feature & its scope.Add Feature Receiver Class & the add below mentioned code :

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
            // Get a reference to a web and a list
            SPWeb web = properties.Feature.Parent as SPWeb;
            string pageURL=web.RootFolder.WelcomePage;
            SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(pageURL  , System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

            // Add the web part
            mgr.AddWebPart(CreatePageWebPart(web.Url), "Left", 1);

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
                // Get a reference to a web and a list
                SPWeb web = properties.Feature.Parent as SPWeb;

PDF Viewer Webpart

Download PDF Viewer Web Part solution & code

Hi, Here now presenting PDF Viewer web part solution with code. You can view any pdf file by providing url of the pdf document or you can use this pdf viewer web part as connected web part also.

When you install this web part , you will see a “View PDF” button in your ribbon of all document libraries.

You can view pdf by clicking on the button from the ribbon.

Download PDF Viewer Web Part solution & code

SharePoint 2013 Important Links

SharePoint Server 2013 Preview Download: SharePoint Foundation 2013 Preview Download: SharePoint 2013 & Office 2013 Training For Developers: SharePoint 2013 Training For IT Pros: Start: Set up the development environment for SharePoint 2013: Cheers

How to calculate difference between two dates in javascript/jquery

Simple steps to calculate difference between two date fields using JavaScript/JQuery  In some scenario, we need to calculate the difference between two dates from the client side. Here we are going to demonstrate all about date fields using javascript such as Javascript date field validation for different format, difference between two dates in days, hours, minutes, seconds, years and weeks Very strong and simple Javascript validation for date fields for format dd/mm/yyyy  Following javascript function simply verify and return result for checking valid date from client side itself. It will automatically validate leap year entries and return correct result. That means if we pass ’29/02/2011′ to the function it will be return false. If we are passing ’29/02/2012′ to the function it will return true. So we don’t need to bother about the leap year or other complex things. function isValidDate(dateStr) { // Date validation Function // Checks For the following valid Date formats: // DD/MM/YYY…

Disable Right click of mouse

How to disable right click functionality from the web page In some of the web page has the requirement to protect source code from the users. Users can right click the page and take the source code. In order protect right click functionality on the web page we can implement javascript functionality to prevent user’s right click on the web page. So user not able to access features available on the right click menus. By implementing javascript method we can identify the right click event from the user by checking the button code and prevent if the user clicks right click. Below mentioned web page prevented to click right click by the user. When the user trying to right click it will return warning message to user and return the action. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DisableRightClick.aspx.cs" Inherits="ExperimentLab.DisableRightClick" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&…