Saturday, January 29, 2011

Maintain Scroll position in div

This javascript is useful for maintaining scroll position in Panel or div tag...

Following code in Script Tag....
window.onload = function(){
var strCook = document.cookie;
var intS = strCook.indexOf("!~");
var intE = strCook.indexOf("~!");
var strPos = strCook.substring(intS+2,intE);
document.getElementById("divTest").scrollTop = strPos;
function SetDivPosition(){
var intY = document.getElementById("divTest").scrollTop;
document.title = intY;
document.cookie = "yPos=!~" + intY + "~!";

Following code in body

< div id="divTest" width:150px;height:200px;overflow:auto" onscroll="SetDivPosition()">
--Gridview (or more data)

Tuesday, January 11, 2011

Check boxes in List box

1.Drop CheckBoxList control on your page.
2.Surround it with
3.Set Overflow style of
to "auto" and size as you like.

< div style="BORDER: thin solid; OVERFLOW: auto; WIDTH: 100px; HEIGHT: 100px">
< asp:checkboxlist id="CheckBoxList1" runat="server">

Thursday, September 2, 2010

Supress C sharp Compiler Warnings

When you compile any c# program it may produce warning & Errors. If your code contains errors it means there is some serious issue. If your code contains warning means it is tolerable.

Compiler has option treat warning as errors in that case your build process fail if your code contains warning.

Some sample code for Warning
class MyProgram
int variable1;
It generates warning :Code111: The field variable1 is never used .
Code111 is Error number. you can supress this warning using Pragma warning compiler directive.

class MyProgram
#pragma warning disable 111 //Here u can give comma separated list of warning numbers
int variable1;

If you want to re-enable warning you can use restore keyword
#pragma warning restore 111 //if used it again it shows the warning