Blog Archive

Search Blog

Blog List

Contact Me






Enter the code shown above in the box below
Send

 

Announcements

Recommended Websites

Events

Event StartEvent EndTitle

Recommended Reading

Most recent blog entries

If you have a DataList control and capture the ItemDataBound event like this:

 

Private Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound

 

And then suddenly have the urge to do something to e.item and expect it to exist after a postback you best be a suppressing that urge because nothing you do to e.item in the ItemDataBound event of a DataList control will survive a postback. The reason is described here:

 

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=104649&wa=wsignin1.0

...

Read More »

You can set the title attribute on the drop down list items to have ToolTip popups on your DropDownList items. This does not work in IE6 but works in IE7. For example you can do it right in the aspx like this:

 

asp:DropDownList ID="DropDownList1" runat="server">

            asp:ListItem title="Choice 1 ToolTip" Value="1">Choice 1asp:ListItem>

            asp:ListItem title="Choice 2 ToolTip" Value="2">Choice 2asp:ListItem>

asp:DropDownList>

 

Visual Studio will say that “Attribute 'title' is not a valid attribute of element 'ListItem'.” but it will run fine.

Or you can do it in the code behind like this:

 

Protected Sub DropDownList1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.DataBound

Dim toolTip As String = string.Empty

For Each item As ListItem In DropDownList1.Items

toolTip = GetToolTips.(Integer.Parse(item.Value))

item.Attributes.Add("title", toolTip)

Next

...

Read More »

Here is an excellent tip to speed up ASP.NET 2.0 Data Binding by avoiding reflection overhead:

http://www.dasblonde.net/CommentView,guid,edc5323f-2afa-4ae5-9513-fbfb380940d4.aspx

And if your in a VB project then of course you have to use CType to cast Container.DataItem like so:

asp:Label ID="Label3" runat="server" Text='CType(Container.DataItem, ConfigurationSection).SectionInformation.SectionName %>'>asp:Label>

Another benefit of doing this early binding, if your using VS 2005, is you get intellisense popup to aid in selecting the right property.

...

Read More »

To access a property on the masterpage in ASP.NET 2.0 you have to cast it like this:

For a Web Application project

CType(MyBase.Master, WebApplication1.Site1)

Or for a website project

CType(MyBase.Master, MasterPage)

Or you can specify the MasterType in the aspx like this:

For a Web Application project

@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Site1.Master" CodeBehind="Default.aspx.vb"

    Inherits="WebApplication1._Default" %>

@ MasterType TypeName="WebApplication1.Site1" %>

Or for a website project

@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb"

    Inherits="Default" title="Untitled Page" %>

@ MasterType VirtualPath="~/MasterPage.master" %>

Which will then create a shadow property on Master that does the casting for you so in the code behind you can just use:

Me.Master

...

Read More »