Full Trust European Hosting

BLOG about Full Trust Hosting and Its Technology - Dedicated to European Windows Hosting Customer

Crystal Report Hosting - HostForLIFE :: Alternate Row Color in Crystal Report

clock August 31, 2021 08:58 by author Peter

Most of the time while developing reports people wonder how to have alternating row colors in the report like below.


There is a cool trick to it.
 

Go to the format section of the Details. Click the Color Tab. Then click the button next to the Background Color CheckBox.

In the formula editor of background color, type the following:



if RecordNumber mod 2 = 0 then crSilver else crNoColor.

Save and close the editor.
 
And now when you run the report you will see alternate colors of silver and white in the details section.



European VB.NET Hosting - HostForLIFE :: Getting an External IP Address Locally using VB.Net

clock August 27, 2021 07:33 by author Peter

This short article shall address the easiest way possible to get your external IP address (and local/internal IP address). There is no particular magic to getting your external IP address; the easiest way I have found is to use the automation service provided by http://whatismyip.com/automation/n09230945.asp, the good folks at whatismyip.com are nice enough to provide a free service to return the external IP address. All that the ask in return is that you do not beat them up with too many requests; they suggest about one every five minutes as being within their comfort zone; however, they also offer to provide additional services upon request so if you need something more than that, give them a call and talk to them about it.

 
Now, if you have a public site and are interested in getting the user's IP address that is really not an issue. You can still just request the REMOTE_ADDR or HTTP_X_FORWARDED_FOR server variable to get that.
 
Code
There is not much code to address in this one. There are three examples to show: the local IP address, the external IP address (for when you might need to see that locally), and the remote IP address.
 
The first example shows how to collect the local IP address; here we use an instance of the IPHostEntry container class to capture the host entry and then we display the first item in the host entry's address list as the local IP address.

    ' Local IP Address (returns your internal IP address)  
    Dim hostName As String = System.Net.Dns.GetHostName()  
    Dim myIPs As IPHostEntry = Dns.GetHostEntry(hostName)  
    Response.Write("<em>Your Local IP Address is:  " & myIPs.AddressList(0).ToString() & "</em><br />")  
 

The next example uses the whatismyip.com automation service to capture the external IP address locally. This value is displayed as the external IP address. If you just need to find out your external IP address, you can use a browser to navigate to the whatismyip.com website and you will see your external IP address displayed on the page; alternatively, you can use another service such as IPChicken.com to perform the same function. If you want to pro-grammatically capture the external IP address locally, this code will do the job.

    ' External IP Address (get your external IP locally)  
    Dim utf8 As New UTF8Encoding()  
    Dim webClient As New WebClient()  
    Dim externalIp As String = _     utf8.GetString(webClient.DownloadData("http://whatismyip.com/automation/n09230945.asp"))  
    Response.Write("<h2>Your External IP Address is: " & externalIp & _  
    "</h2><br />")  

If you are working from a public website and you want to capture the user's IP address; the following code will do the job.
    ' Remote IP Address (useful for getting user's IP from public site; run locally it just returns localhost)  
    Dim remoteIpAddress As String = Request.ServerVariables("HTTP_X_FORWARDED_FOR")  
    If (String.IsNullOrEmpty(remoteIpAddress)) Then  
    remoteIpAddress = Request.ServerVariables("REMOTE_ADDR")  
    End If  
    Response.Write("<em>Your Remote IP Address is:  " + remoteIpAddress + "</em><br />")  

 
This article was intended to show some simple ways to capture IP address information under different circumstances. The three examples show demonstrate how to capture the local IP address, how to capture the external IP address locally, and how to capture the user's IP address from a public website.



Crystal Report Hosting - HostForLIFE :: How to Print a Crystal Report Programmatically in ASP.NET?

clock August 6, 2021 08:42 by author Peter

You can print a Crystal Report using the print option of Crystal Report Viewer. However, there are occasions when you want your application to print a report directly to the printer without viewing the report in Crystal Report Viewer.
 

The ReportDocument class provides PrintToPrinter method that may be used to print a CR direct to the printer. If no printer is selected, the default printer will be used to send the printing pages to.
 
The PrintToPrinter method takes four parameters.
 
nCopies : Indicates the number of copies to print.
collated : Indicates whether to collate the pages.
startPageN : Indicates the first page to print.
endPageN : Indicates the last page to print.
 
The following steps will guide you to achieve the same:
    Add a crystal report (.cr) file to your ASP.NET application.
    Add a report instance on the page level.
        Dim report As MyReport = New MyReport

    Populate reports data on Page_Init
        ' Get data in a DataSet or DataTable  
          
        Dim ds As DataSet = GetData()  
        ' Fill report with the data  
        report.SetDataSource(ds)

    Print Report
        report.PrintToPrinter(1, False, 0, 0)


If you wish to print a certain page range, change the last two parameters From To page number.
 
If you want to set page margins, you need to create a PageMargin object and set PrintOptions of the ReportDocument.
 
The following code sets page margins and printer name:
    Dim margins As PageMargins =  Report.PrintOptions.PageMargins  
       margins.bottomMargin = 200  
       margins.leftMargin = 200  
       margins.rightMargin = 50  
       margins.topMargin = 100  
       Report.PrintOptions.ApplyPageMargins(margins)  
       
       ' Select the printer name  
       Report.PrintOptions.PrinterName = printerName



Ajax Hosting UK - HostForLIFE :: Render API Using AJAX Call

clock August 3, 2021 07:57 by author Peter

In this article, we will discuss how to invoke API using the AJAX call. We use the AJAX call because it allows the user to update a web page without reloading the page, request data from a server after the page has loaded, receive data from a server after the page has loaded, and send the data to a server in the background.

 
The below HTTP verb is used to call a particular Web API call. Here is the mapping sequence.
    POST - Create
    GET - Read
    PUT - Update
    DELETE - delete

    var person = new Object();    
    person.name = $('#name').val();    
    person.surname = $('#surname').val();    
    $.ajax({    
        url: 'http://localhost:3413/api/person',    
        type: 'POST',    
        dataType: 'json',    
        data: person,    
        success: function (data, textStatus, xhr) {    
            console.log(data);    
        },    
        error: function (xhr, textStatus, errorThrown) {    
            console.log('Error in Operation');    
        }    
    });  


In the above code, we pass the person data to the API using the Post method.
 
You can call the API using the above code for different uses, like Delete record, Update record, and Get records using Get, Put, and Delete type keywords.

HostForLIFE.eu AJAX Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.

 



About HostForLIFE

HostForLIFE is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2019 Hosting, ASP.NET 5 Hosting, ASP.NET MVC 6 Hosting and SQL 2019 Hosting.


Tag cloud

Sign in