Solution
Step 1
Paste this code on export button click.
Protected Sub imgExport_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgExport.Click
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=filename.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim stringWrite As New StringWriter
Dim htmlWrite As New HtmlTextWriter(stringWrite)
grid.AllowSorting = False
grid.AllowPaging = False
subBindGrid()
grid.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()
grid.AllowSorting = True
grid.AllowPaging = True
subBindGrid()
End Sub
If u run this code now, you will get error - 'Control 'ctl00_ContentPlaceHolder1_grid' of type 'GridView' must be placed inside a form tag with runat=server'. so, Don't worry. Just follow Step 2.
Step 2
Just copy and paste the below code. Its done.
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
' Confirms that an HtmlForm control is rendered for the specified ASP.NET
' server control at run time.
End Sub
Friday, October 22, 2010
Tuesday, September 28, 2010
Merging Pdf files in Asp.Net
Solution
1. First u need to download 'itextsharp.dll' from the internet.
2. Then add this dll using add reference.
3. Import the below name space.
Imports iTextSharp.text
Imports iTextSharp.text.pdf
4. Use the below function to merge the pdf.
Public Sub Merge()
Private ReadOnly m_documents As List(Of PdfReader)
Dim newDocument As Document = Nothing
//Merge pdf path. All the pdf files will merged here and become one pdf.
ByVal outputStream As Stream
outputStream = New FileStream(pdfMergePath, FileMode.Create)
Try
newDocument = New Document()
Dim pdfWriter__1 As PdfWriter = PdfWriter.GetInstance(newDocument, outputStream)
newDocument.Open()
newDocument.SetPageSize(PageSize.A3)
Dim pdfContentByte__2 As PdfContentByte = pdfWriter__1.DirectContentUnder
// Add all the pdf to merge
m_documents.Add(New PdfReader(pdfPath1))
m_documents.Add(New PdfReader(pdfPath2))
m_documents.Add(New PdfReader(pdfPath2))
For Each doc In m_documents
totalPages += doc.NumberOfPages
Next
Dim currentPage As Integer = 1
For Each pdfReader As PdfReader In m_documents
For page As Integer = 1 To pdfReader.NumberOfPages
newDocument.NewPage()
Dim importedPage As PdfImportedPage = pdfWriter__1.GetImportedPage(pdfReader, page)
pdfContentByte__2.AddTemplate(importedPage, 0, 0)
pdfContentByte__2.BeginText()
m_baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
pdfContentByte__2.SetFontAndSize(m_baseFont, 9)
pdfContentByte__2.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, String.Format("{0} of {1}", currentPage, totalPages), 520, 5, 0)
pdfContentByte__2.EndText()
currentPage = currentPage + 1
Next
Next
Finally
outputStream.Flush()
If newDocument IsNot Nothing Then
newDocument.Close()
End If
outputStream.Close()
End Try
End Sub
1. First u need to download 'itextsharp.dll' from the internet.
2. Then add this dll using add reference.
3. Import the below name space.
Imports iTextSharp.text
Imports iTextSharp.text.pdf
4. Use the below function to merge the pdf.
Public Sub Merge()
Private ReadOnly m_documents As List(Of PdfReader)
Dim newDocument As Document = Nothing
//Merge pdf path. All the pdf files will merged here and become one pdf.
ByVal outputStream As Stream
outputStream = New FileStream(pdfMergePath, FileMode.Create)
Try
newDocument = New Document()
Dim pdfWriter__1 As PdfWriter = PdfWriter.GetInstance(newDocument, outputStream)
newDocument.Open()
newDocument.SetPageSize(PageSize.A3)
Dim pdfContentByte__2 As PdfContentByte = pdfWriter__1.DirectContentUnder
// Add all the pdf to merge
m_documents.Add(New PdfReader(pdfPath1))
m_documents.Add(New PdfReader(pdfPath2))
m_documents.Add(New PdfReader(pdfPath2))
For Each doc In m_documents
totalPages += doc.NumberOfPages
Next
Dim currentPage As Integer = 1
For Each pdfReader As PdfReader In m_documents
For page As Integer = 1 To pdfReader.NumberOfPages
newDocument.NewPage()
Dim importedPage As PdfImportedPage = pdfWriter__1.GetImportedPage(pdfReader, page)
pdfContentByte__2.AddTemplate(importedPage, 0, 0)
pdfContentByte__2.BeginText()
m_baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
pdfContentByte__2.SetFontAndSize(m_baseFont, 9)
pdfContentByte__2.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, String.Format("{0} of {1}", currentPage, totalPages), 520, 5, 0)
pdfContentByte__2.EndText()
currentPage = currentPage + 1
Next
Next
Finally
outputStream.Flush()
If newDocument IsNot Nothing Then
newDocument.Close()
End If
outputStream.Close()
End Try
End Sub
Browser display area or view port width & height using Javascript
Solution
The below script will help u to get the width and height of the browser view port area.
function fnScreenWidth() {
//for IE
var viewportwidth;
var viewportheight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) //use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') {
viewportwidth = window.innerWidth;
viewportheight = window.innerHeight;
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the //first line in the document)
else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
viewportwidth = document.documentElement.clientWidth;
viewportheight = document.documentElement.clientHeight;
}
// older versions of IE
else {
viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
viewportheight = document.getElementsByTagName('body')[0].clientHeight;
}
alert('Your viewport width is ' + viewportwidth + 'x' + viewportheight);
}
You can call this java script from body tag,
body onload="fnScreenWidth()"
The below script will help u to get the width and height of the browser view port area.
function fnScreenWidth() {
//for IE
var viewportwidth;
var viewportheight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) //use window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') {
viewportwidth = window.innerWidth;
viewportheight = window.innerHeight;
}
// IE6 in standards compliant mode (i.e. with a valid doctype as the //first line in the document)
else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
viewportwidth = document.documentElement.clientWidth;
viewportheight = document.documentElement.clientHeight;
}
// older versions of IE
else {
viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
viewportheight = document.getElementsByTagName('body')[0].clientHeight;
}
alert('Your viewport width is ' + viewportwidth + 'x' + viewportheight);
}
You can call this java script from body tag,
body onload="fnScreenWidth()"
Get Physical Path of Application in ASP.Net
Solution
HttpRuntime.AppDomainAppPath
This wil gets the physical drive path of the application directory for the application hosted in the current application domain.
HttpRuntime.AppDomainAppPath
This wil gets the physical drive path of the application directory for the application hosted in the current application domain.
Monday, September 27, 2010
Accessing session in a class file in Asp.Net
Solution
The Session property provides programmatic access to the properties and methods of the HttpSessionState class. Because, ASP.NET pages contain a default reference to the System.Web namespace (which contains the HttpContext class), you can reference the members of HttpContext on an .aspx page without the fully qualified class reference to HttpContext. For example, you can use just Session("SessionVariable1") to get or set the value of the session state variable SessionVariable1. However, class file will not inherit System.web namespace. So we need access like below,
HttpContext.Current.Session("Session_Name")
The Session property provides programmatic access to the properties and methods of the HttpSessionState class. Because, ASP.NET pages contain a default reference to the System.Web namespace (which contains the HttpContext class), you can reference the members of HttpContext on an .aspx page without the fully qualified class reference to HttpContext. For example, you can use just Session("SessionVariable1") to get or set the value of the session state variable SessionVariable1. However, class file will not inherit System.web namespace. So we need access like below,
HttpContext.Current.Session("Session_Name")
Password Encoding and Decoding in ASP.Net
Encoding
Public Function fnBase64Encode(ByVal strPwd As String) As String
Dim byteEncode(strPwd.Length) As Byte
Dim strEncoded As String
byteEncode = System.Text.Encoding.UTF8.GetBytes(strPwd)
strEncoded = Convert.ToBase64String(byteEncode)
Return strEncoded
End Function
Decoding
Public Function fnBase64Decode(ByVal strPwd As String) As String
Dim encoder As New System.Text.UTF8Encoding()
Dim utf8Decode As System.Text.Decoder
Dim byteDecode() As Byte
Dim intCharCnt As Integer
Dim strDecoded As String
utf8Decode = encoder.GetDecoder()
byteDecode = Convert.FromBase64String(strPwd)
intCharCnt = utf8Decode.GetCharCount(byteDecode, 0, byteDecode.Length)
Dim charDecoded(intCharCnt) As Char
utf8Decode.GetChars(byteDecode, 0, byteDecode.Length, charDecoded, 0)
strDecoded = New String(charDecoded)
Return strDecoded
End Function
Public Function fnBase64Encode(ByVal strPwd As String) As String
Dim byteEncode(strPwd.Length) As Byte
Dim strEncoded As String
byteEncode = System.Text.Encoding.UTF8.GetBytes(strPwd)
strEncoded = Convert.ToBase64String(byteEncode)
Return strEncoded
End Function
Decoding
Public Function fnBase64Decode(ByVal strPwd As String) As String
Dim encoder As New System.Text.UTF8Encoding()
Dim utf8Decode As System.Text.Decoder
Dim byteDecode() As Byte
Dim intCharCnt As Integer
Dim strDecoded As String
utf8Decode = encoder.GetDecoder()
byteDecode = Convert.FromBase64String(strPwd)
intCharCnt = utf8Decode.GetCharCount(byteDecode, 0, byteDecode.Length)
Dim charDecoded(intCharCnt) As Char
utf8Decode.GetChars(byteDecode, 0, byteDecode.Length, charDecoded, 0)
strDecoded = New String(charDecoded)
Return strDecoded
End Function
The maximum report processing jobs limit configured by your system administrator has been reached.
Possible Causes
The error message appears because the web application has exceeded the Crystal Reports reporting engine default print job limit of 75. Or, in other words, a high reporting load has been placed on the reporting engine. There are a number of reasons why the report engine would suffer from high loads and each reason may have a distinct solution as documented below.
Coding Issues
Proper coding requires that any objects be managed and thus destroyed when they are no longer needed. This is true for any object that supports IDisposable interface.
Too Many Print Jobs Submitted to the Report Engine
Starting in version 10 of Crystal Reports, the reporting engine was optimized for greatest report throughput. There are specific registry keys that control this optimization. By default, the print job limit is set to 75 print jobs. When a load is placed on the application it can hit the 75 print job limit and cause the error. Note that a print job includes main reports, subreports, and in-session report objects (e.g.; drill down, paging, searching, and more.). Therefore a single report could exceed the 75 print job limit. Consider a report that returns 75 records, with a subreport placed in the detail section and thus running for each record. This report will need to run 75 subreports plus the main report, reaching 76 print jobs and the error will be thrown.
Solutions
First Delete report files in temp folder(C:\Documents and Settings\[UserName]\Local Settings\Temp) with the extension rpt.
1. Dispose un-needed objects on Page_Unload
Ensure that you call .Dispose and .Close method when the report object is no longer need. Also, ensure that this is done not only with Crystal Reports, but FileStream, Database Connections, datasets or any other object that supports IDisposable interface.
Dim cryDoc As ReportDocument
On page Unload dispose the Report Document Object.
rDoc.Close()
rDoc.Dispose()
This is the Correct Solution.
2. Increase the 75 Print Job Limit
This may stop the error from occurring temporarily but as load increases, you will find the error will start to occur again or worse yet, the system may stop responding and a system reboot will be the only way to recover. For an application using the Crystal reports SDK, the registry key “InprocServer” sets the limit for the number of print jobs allowed to be processed by the report engine.
Note: The default value of 75 is the predetermined value for best performance in tested environments. Changing this value may affect performance of the system.
To change the PrintJobLimit value, follow these steps:
1)Click Start > Run. The Run dialog box appears.
2)Type “regedit” in the Open field. Click OK. The Registry Editor appears.
Navigate to the appropriate registry key value as documented below.
Crystal Reports 10.0.x
HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.0\Report Application Server\ InprocServer\PrintJobLimit
Crystal Reports 10.2 (Visual Studio .NET 2005 bundle)
HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\ InprocServer\PrintJobLimit
Crystal Reports Basic for Visual Studio 2008 (Visual Studio .NET 2008 bundle)
HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\10.5\report Application server\InProcServer\ PrintJobLimit\PrintJobLimit
Crystal Reports XI Release 1 (11.0.x)
HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.0\Report Application Server\InprocServer\PrintJobLimit
Crystal Reports XI Release 2 (11.5.x)
HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.5\Report Application Server\InprocServer\PrintJobLimit
Crystal Reports 2008 (12.x.x)
HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocServer\PrintJobLimit
The error message appears because the web application has exceeded the Crystal Reports reporting engine default print job limit of 75. Or, in other words, a high reporting load has been placed on the reporting engine. There are a number of reasons why the report engine would suffer from high loads and each reason may have a distinct solution as documented below.
Coding Issues
Proper coding requires that any objects be managed and thus destroyed when they are no longer needed. This is true for any object that supports IDisposable interface.
Too Many Print Jobs Submitted to the Report Engine
Starting in version 10 of Crystal Reports, the reporting engine was optimized for greatest report throughput. There are specific registry keys that control this optimization. By default, the print job limit is set to 75 print jobs. When a load is placed on the application it can hit the 75 print job limit and cause the error. Note that a print job includes main reports, subreports, and in-session report objects (e.g.; drill down, paging, searching, and more.). Therefore a single report could exceed the 75 print job limit. Consider a report that returns 75 records, with a subreport placed in the detail section and thus running for each record. This report will need to run 75 subreports plus the main report, reaching 76 print jobs and the error will be thrown.
Solutions
First Delete report files in temp folder(C:\Documents and Settings\[UserName]\Local Settings\Temp) with the extension rpt.
1. Dispose un-needed objects on Page_Unload
Ensure that you call .Dispose and .Close method when the report object is no longer need. Also, ensure that this is done not only with Crystal Reports, but FileStream, Database Connections, datasets or any other object that supports IDisposable interface.
Dim cryDoc As ReportDocument
On page Unload dispose the Report Document Object.
rDoc.Close()
rDoc.Dispose()
This is the Correct Solution.
2. Increase the 75 Print Job Limit
This may stop the error from occurring temporarily but as load increases, you will find the error will start to occur again or worse yet, the system may stop responding and a system reboot will be the only way to recover. For an application using the Crystal reports SDK, the registry key “InprocServer” sets the limit for the number of print jobs allowed to be processed by the report engine.
Note: The default value of 75 is the predetermined value for best performance in tested environments. Changing this value may affect performance of the system.
To change the PrintJobLimit value, follow these steps:
1)Click Start > Run. The Run dialog box appears.
2)Type “regedit” in the Open field. Click OK. The Registry Editor appears.
Navigate to the appropriate registry key value as documented below.
Crystal Reports 10.0.x
HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.0\Report Application Server\ InprocServer\PrintJobLimit
Crystal Reports 10.2 (Visual Studio .NET 2005 bundle)
HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\ InprocServer\PrintJobLimit
Crystal Reports Basic for Visual Studio 2008 (Visual Studio .NET 2008 bundle)
HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\10.5\report Application server\InProcServer\ PrintJobLimit\PrintJobLimit
Crystal Reports XI Release 1 (11.0.x)
HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.0\Report Application Server\InprocServer\PrintJobLimit
Crystal Reports XI Release 2 (11.5.x)
HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 11.5\Report Application Server\InprocServer\PrintJobLimit
Crystal Reports 2008 (12.x.x)
HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocServer\PrintJobLimit
Thursday, July 17, 2008
Jesus Christ

Jesus Christ biography
Unlike most biographies, the Jesus Christ biography does not begin with His birth, or even with His conception. Jesus Christ's biography can be understood more fully if we realize the Bible uses many names to refer to Jesus Christ. John referred to Jesus Christ as "the Word" when he wrote, "In the beginning was the Word, and the Word was with God, and the Word was God. He was with God in the beginning" (John 1:1-2). This tells us that the Jesus Christ biography begins in eternity past - with God.
The first recorded acts in Jesus Christ's biography go back to creation. "Through him all things were made; without him nothing was made that has been made" (John 1:3). Although not mentioned by name, this Scripture tells us that He was there, and Scripture records God's words as "Let US make man in OUR image, in OUR likeness. . ." (Genesis 1:26), indicating that the Father was not alone at the time of creation.
Birth:
Some would think of a Jesus Christ biography in terms of His life here on earth. For that we must begin not at His birth but at His conception, for both of these events were unlike any other in history. The earthly life of Jesus is the only one that begins with a spiritual conception, with no man present. This conception was foretold by the angel Gabriel in Luke 1:26-35. His birth was the only one to ever open a womb, since He was born of a young Jewish virgin. Because of a government census His mother, Mary, and His stepfather, Joseph, had to travel to Bethlehem. This is where Jesus was born in a lowly stable. His birth was announced by angels to shepherds, and by a special star to wise men in a far country. At eight days of age, he was dedicated in the Temple according to Jewish custom.
Childhood:
At an early age, Jesus and his family fled to Egypt because an angel warned Joseph in a dream of impending danger. When they returned from Egypt, they settled in Galilee, in the town of Nazareth. At the age of twelve, Jesus traveled to Jerusalem with Mary and Joseph to celebrate the Feast of the Passover. When His parents could not find Him in their group of relatives and friends on the return trip, they returned to Jerusalem and "After three days they found Him in the temple courts, sitting among the teachers, listening to them and asking them questions. Everyone who heard Him was amazed at His understanding and His answers. When His parents saw Him, they were astonished. His mother said to Him, 'Son, why have you treated us like this? Your father and I have been anxiously searching for you.' 'Why were you searching for me?' he asked. 'Didn't you know I had to be in my Father's house?' "(Luke 2:46-49). After that, He returned to Nazareth with them, was obedient, and continued to grow "in wisdom and stature, and in favor with God and men." (Luke 2:52)
Adult/ Public Ministry:
At approximately 30 years of age, Jesus entered into the public awareness. John the Baptist had preached of the coming Messiah, preparing the way for Jesus' ministry. John baptized Jesus, and as Jesus prayed at the time of His baptism, "heaven was opened and the Holy Spirit descended on Him in bodily form like a dove. And a voice came from heaven: 'You are my Son, whom I love; with you I am well pleased.'" (Luke 3:21-22). After this, Jesus went into the wilderness for a time of fasting and prayer in preparation for His ministry. Then the devil came to Him and tempted Him. Rather than succumbing to the temptations, Jesus answered with Scripture, setting a pattern for His followers to handle temptations for ages to come.
Jesus began to preach a message of repentance, and from among His followers hand-picked twelve men with whom He worked most closely, teaching them even more intensely than to the multitudes. These men have come to be known as the twelve disciples, or the apostles. The teaching and preaching of Jesus convicted, challenged, or encouraged those who heard, while some were simply entertained and others were angered. Jesus performed many miracles of healing and restoration, as well as miracles designed to teach a lesson.
A Jesus Christ biography is intensely interesting - and can be studied in depth in the pages of Scripture, especially the Gospels of Matthew, Mark, Luke, and John. However, the primary reason for Jesus' earthly life was "to seek and to save that which was lost." (Luke 19:10) Jesus sought the lost through His teaching and preaching. Then He provided the way of salvation from sin (the only way to Heaven) by way of the ultimate sacrifice, the one that only He could make - His crucifixion on Calvary, followed by His resurrection from the dead after three days. Thus He conquered death and the grave for all who would put their faith in Him.
Subscribe to:
Posts (Atom)