By Darren McLeod on
Saturday, November 24, 2007 12:09 PM
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 »
|
By Darren McLeod on
Wednesday, November 21, 2007 5:32 AM
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 »
|
By Darren McLeod on
Saturday, November 10, 2007 10:31 AM
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 »
|
By Darren McLeod on
Saturday, November 03, 2007 10:03 AM
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 »
|
By Darren McLeod on
Wednesday, October 31, 2007 7:55 AM
Finally managed to get my DNN v4.6.2 install into the root, thanks to http://www.bahrenburgs.com/Default.aspx?tabid=58&EntryID=3. My problem was I had tried darrenmcleod.com/ as the portal alias but it kept giving me an infinite redirect error. Then I tried darrenmcleod.com as the portal alias as bahrenburgs suggested and everything is goodness. Note that when you make a change like this just through the database you need to do something to cause your application to reload, like editing a line in web.config and saving it.
|
By Darren McLeod on
Sunday, October 21, 2007 8:38 AM
A good guide to the ASP.NET 2.0 Wizard Control can be found here http://steveorr.net/articles/Wizard.aspx
I wanted to have the Wizard Control Header display the current step’s title, after a little research I found that the ActiveStepChanged event would allow me to do this. So I added an event handler like this:
Protected Sub Wizard1_ActiveStepChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Wizard1.ActiveStepChanged
Me.Wizard1.HeaderText = Me.Wizard1.ActiveStep.Title
End Sub
Except it didn’t set the Header for the first step so I set the HeaderText manually to the first step’s title like this:
asp:Wizard ID="Wizard1" runat="server" HeaderText="Step 1">
WizardSteps>
asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
asp:WizardStep>
asp:WizardStep ID="WizardStep2"...
Read More »
|
By Darren McLeod on
Wednesday, October 17, 2007 9:22 PM
Add a property to your WebUserControl:
Private widthValue As Integer
Public Property Width() As Integer
Get
Return widthValue
End Get
Set(ByVal value As Integer)
widthValue = value
End Set
End Property
Then add a prerender event handler to the WebUserControl, where in this example the MainTable happens to be the outermost container element in the Web User Control with a width attribute:
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
If Me.Width > 0 Then
Me.MainTable.Width = Me.Width
End If
End Sub
Then where ever you use the control you can specify the width if you want to:
uc2:MyWebUserControl ID="MyWebUserControl1" runat="server" width="650" />
...
Read More »
|
By Darren McLeod on
Wednesday, October 17, 2007 9:19 PM
With this html:
All
Company 1
Company 2
Company 3
Company 4
Company 5
In my webtest I wanted to verify CompanyDropDownList had selected option 2 "Company 1".
Tried Form Field with form field name ctl00$ContentPlaceHolder1$CompanyDropDownList but it did not work.
Using Required Attribute Value worked with the following values:
Attribute Name value
Expected Value 2
Ignore Case False
Match Attribute Name selected
Match Attribute Value selected
Tag Name option
...
Read More »
|