Decrease Font Size
Increase Font Size
   BLOG

Data is Null This method or property cannot be called on Null values

by bryian 9. January 2010 09:14

I was working on one of the VB.NET application that have been developed several years ago and I saw some declaration like Str7 = objDr.GetString(7).ToString, Str8 = objDr.GetString(8).ToString, Str9 = objDr.GetString(9).ToString and so on. It puzzled me, what will happen if the value in the column 7, 8, or 9 is null. Then, I went in to the SQL database, pull out the table and changed the value to null. And I received this error "

Data is Null. This method or property cannot be called on Null values.

" If you happen to come across this situation, below is the work around.

 

Solution:

If (Not objDr(8) Is DBNull.Value) Then
     Str8 = Trim(objDr.GetString(8).ToString)
End If

Extender control ValidatorCalloutExtender cannot extend TextBox

by bryian 6. January 2010 19:52

Extender control 'ValidatorCalloutExtender1' cannot extend 'TextBox1'. Extender controls of type 'AjaxControlToolkit.ValidatorCalloutExtender' cannot extend controls of type 'System.Web.UI.WebControls.TextBox'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Extender control 'ValidatorCalloutExtender1' cannot extend 'TextBox1'. Extender controls of type 'AjaxControlToolkit.ValidatorCalloutExtender' cannot extend controls of type 'System.Web.UI.WebControls.TextBox'.

 

Solution: Make sure the TargetControlID of the ValidatorCalloutExtender is set to a validator control instead of the TextBox control

Example:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

   <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
        ErrorMessage="Required field" Display="None" 
        ControlToValidate="TextBox1" />
        
   <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" 
        TargetControlID="RequiredFieldValidator1" runat="server" />

missing HtmlHead control which is required for the CSS stylesheet link

by bryian 6. January 2010 17:52

ValidatorCalloutExtender | System.NotSupportedException

I upgraded one of the ASP.NET Web applications from 1.0 to 3.5. Everything went smoothly. Then I tried to use the ValidatorCalloutExtender and received the errors shown below.

This page is missing a HtmlHead control which is required for the CSS stylesheet link that is being added. Please add <head runat="server" />.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: This page is missing a HtmlHead control which is required for the CSS stylesheet link that is being added. Please add .

 

Solution: include runat="server" in the head tag

Tags: , ,

Error