Wednesday, October 6, 2010

How do I open PDF's to specific pages?

Open a PDF to a specific page from a web-server
1. Use name/destination pairs when you Distill your PDF document. Please refer to the https://partners.adobe.com/asn/acrobat/sdk/explodedSDK/Documentation/PDF_Creation_APIs/pdfmarkReference.pdf This is designed for PostScript engineers or for those who are generating their own PostScript.
2. Use a highlight file.
3. append #page=x [where x is the page number].
4. Select File > Document Properties > Open Options and target the page and view you want. This is the easiest, but least flexible method, as you get exactly one view that you can open to.

JavaScript function to check/Uncheck all the check boxes on a form

function CheckAll(flag) {
var fmobj = document.friendbox;
for (var i=0;i {
var e = fmobj.elements[i];
if(e.type=='checkbox')
{
if(flag=='false')
e.checked = false;
else
e.checked = true;
}
}
}

javascript to get values of query string variable:

var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}

Javascript: Function to get Cookies values

function getCookiesValue(objCkNm)
{
var beginindex, endindex, result, num;
num = objCkNm.length;
beginindex=document.cookie.indexOf(objCkNm) + num +1 ;
endindex=beginindex;
//while we haven't hit ";" and it's not end of cookie
while (document.cookie.charAt(endindex)!=";" && endindex <= document.cookie.length)
endindex++

//result contains "JavaScript Kit"
result=document.cookie.substring(beginindex,endindex)
return result;
}

Javascript: function to check that number is numeric

function IsNumeric(strString)
{
// check for valid numeric strings
var strValidChars = "0123456789.-";
var strChar;
var blnResult = true;

if (strString.length == 0) return false;

// test strString consists of valid characters listed above
for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
{
blnResult = false;
}
}
return blnResult;
}

Javascript: Email Validation function

function ValidateEmail(str)
{
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1)
{
alert("The eMail address '@' convention appears to be invalid.")
return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
{
alert("The eMail address '@' convention appears to be invalid.")
return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("The eMail address 'dot' convention appears to be invalid.")
return false
}

if (str.indexOf(at,(lat+1))!=-1)
{
alert("The eMail address '@' convention appears to be invalid.")
return false
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
{
alert("The eMail address 'dot' convention appears to be invalid.")
return false
}

if (str.indexOf(dot,(lat+2))==-1)
{
alert("The eMail address 'dot' convention appears to be invalid.")
return false
}

if (str.indexOf(" ")!=-1)
{
alert("The eMail address spacing convention appears to be invalid.")
return false
}
return true
}

Javascirpt : . function to Remove spaces

function removeSpaces(string) {
var tstring = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
tstring += splitstring[i];
return tstring;
}

This function used with the onclick event of File Html Control, this shows the image when You click on the / File Html Control or “Browse” image

function DoPreview()
{
var filename = document.form1.filesent.value;
var Img = new Image();
if (navigator.appName == "Netscape")
{
alert("Previews do not work in Netscape.");
}
else
{
Img.src = filename;
document.images[0].src = Img.src;
}
}

How to register dot net framework

  1. Download the framework from the Microsoft
  2.  install the framework from the executable site
  3. registration
    1. Open the Command Prompt
    2. Go to the path where Framework installed
    3. Execute the command "aspnet_regiis -i" to register the .Net framework

DataGrid Export to excel file

private void ExportGridToExcel(DataGrid grdGridView, string fileName)
{
Response.Clear();
Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xls", fileName));
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
grdGridView.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}