Home » .Net » ASP.NET

Category Archives: ASP.NET

Categories

iTextSharp – Insert an Image to a PDF in C#

iTextSharp PDF

Using iTextSharp to Generate a PDF

In this article I will cover some of the basics of inserting an image into a PDF that you are generating with iTextSharp in either C# or VB.NET. This includes:

  1. Adding your image programmatically while generating your PDF
  2. Adjusting your image scaling so it renders nicely in your PDF
  3. Positioning your image in your PDF
  4. Example code in C#
  5. Example code in VB.NET

If you are interested in working with the iTextSharp .NET libraries then have a look at some of the other articles covering iTextSharp I have written on the topic. (more…)

About these ads

ASP.NET Get the Current Web Page Name

ASP.NET

ASP.NET

I’m taking a look into some of the basic commands in ASP.NET that you can use to find the name of the Web page that is currently running the script as well as important parts of the URL of the current page. For clarity I’ll review the same commands in both C# and VB.NET.

In both VB.NET and C# you can find the current page name using:

  • System.IO.Path.GetFileName
  • System.IO.FileInfo
  • System.Web.VirtualPathUtility.GetFileName

If you find this article useful, check out some other ASP.NET tips I have written. (more…)

ShowModalDialog Example – How to Save Popup Form Information and Close the Modal Popup Window

ShowModalDialog

ShowModalDialog

In this article I will go through a technique that you can use when working with a modal popup that lets you store form information from your popup to later use with your main Web form.

In earlier articles I have covered some of the general functions and benefits of using the ShowModalDialog function that I will expand on this article. If you have questions about some of the code I’ve used in this article, then please take a look at my earlier articles that might help explain some of the concepts:

  1. showModalDialog Opens a New Window on Submit or location.href
  2. ShowModalDialog – Example Code and Some Tips (more…)

ASP.NET – Handling Null Return Values from the Database using IsDBNull

ASP.NET

ASP.NET

If you are retrieving or adding values from and to your database then you will know the difficulties that can be caused by NULL values. The notorious InvalidCastException is one example of receiving a NULL value from your database into an ASP.NET object that doesn’t know what to do with database NULL values.

Here’s typical example of an InvalidCastException error caused by setting a String variable to a value that is returned as a NULL from your database query:

System.InvalidCastException: Conversion from type 'DBNull' to type 'String' is not valid. at Microsoft.VisualBasic.CompilerServices.Conversions.ToString(Object Value) at ASP.myPageName_aspx.Page_Load(Object sender, EventArgs e) in D:\Inetpub\wwwroot\MySite\myPageName.aspx:line 1xx

If you find this article useful, have a look at some of the other ASP.NET tips and tricks articles I’ve published. (more…)

Setting a Time Form Field with a JQuery DatePicker with an ASP.NET DataList in an UpdatePanel

Sometimes you will want to do something very specific on a Web page using a combination of popular technologies. However the interaction of client and server-side languages such as JQuery and ASP.NET can become confusing, especially when the server side language starts adding client-side functionality such as through an UpdatePanel control.

In this article I’m going to review a very specialized case. Here are the key points that I want the code to handle:

  1. I have an ASP.NET DataList that is showing rows of information.
  2. One column of repeating information in the DataList contains a separate Date and Time component
  3. The footer of the DataList is being used to add new rows of information, including a Date and a Time field
  4. The editable time field should display a JQuery DatePicker widget
  5. When a date is selected on the JQuery DatePicker widget, the current time should be set to a separate text field that is beside the Date field
  6. The DataList is running inside an UpdatePanel control to only refresh the DataList when Server communications happens
  7. The DataList has an edit button which the user can press to make a row editable. This involves a refresh of the DataList so that JQuery has to know to re-attach the DatePicker control to the newly editable date field

This is a lot of functionality to cover in one article and I hope it is clear for you to understand how I want the JQuery to interact with the ASP.NET. To further explain things I will give some example code of both the JQuery and the markup tags of the DataList, and I will explain how to address the requirements step-by-step.

Before I start into in-depth explanations in this article, I’d like to mention that if you are interested in reading more about ASP.NET, please check out my series of articles covering ASP.NET development. I also have written a very interesting series of articles about using JQuery to add functionality to your pages that is worth taking a look at.

(more…)

Follow

Get every new post delivered to your Inbox.

Join 1,409 other followers