showModalDialog and ASP .Net

This type of error can get you wound up. I was using showModalDialog to open a new window and return values from a list. Every time I hit OK or Cancel, a new window would be spawned.

Turned out to be a simple fix. Just add the line below into the <HEAD> section of the page being opened.

<base target=_self>

Invisible Prey

There’s more than one way to get a good bargain on antiques…

Invisible Prey (Lucas Davenport Mysteries)

Broken Prey

A student in training demonstrates his newly honed skills.

Broken Prey (Lucas Davenport Mysteries)

.Net treeview selecting nodes

The treeview control has a lot going for it, but it is lacking any sort of ability to maintain state of the currently selected node. This becomes an issue when you want to change/maintain a property on a selected node.

An example would be a treeview of urls where you want to set the backcolor of the selected node after navigating to the new page.

The only way I found to resolve this issue is to store the node.valuepath in a session variable and reselect it during the page_load event.

First, make sure none of your urls are in the NavigateUrl property. This puts the treeview into “Navigation” mode and results in the OnSelectedNodeChanged event not firing. Urls go in the Value property.

Be sure to change your treeview PathSeparator to something like “|” or something other than the default “/”. If you forget to change the default value, it will cause all sorts of problems when using FindNode.

Next, add some code to catch the selectednode.valuepath


Private Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged
Session("selected") = TreeView1.SelectedNode.ValuePath
Response.Redirect(TreeView1.SelectedNode.Value, "false")
End Sub

Finally, add code to the pageload or init event:


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("selected") <> "" Then
TreeView1.FindNode(Session("selected")).Select()
End If
End Sub

Multiple IIS sites on XP Pro

You can configure multiple IIS sites in XP Pro, but you can only have one running at a time. Not sure why the MMC won’t let you do it, but there is an easy work around.

From the \Inetpub\Adminscripts directory

Find out what the highest numbered site is:

adsutil.vbs ENUM /P W3SVC

To create a new site:

adsutil.vbs COPY W3SVC/1 W3SVC/x

where x is the # of the new site

Here are the detailed instructions.

I have found this to be useful when testing .Net apps without wanting to launch studio.

Jesse James: Last Rebel of the Civil War

Gives a very detailed and interesting history of the civil war in Missouri that raged within the Civil War. A great deal of information on Jesse’s time with “Bloody Bill” Anderson is provided. Also, Frank’s exploits with Quantrill are also detailed. Some of the political discussion is a bit dry, but doesn’t diminish the overall content.

Jesse James: Last Rebel of the Civil War

John Maynard Keynes

Investing is an activity of forecasting the yield on assets over the life of the asset;…speculation is the activity of forecasting the psychology of the market.

ObjectDataSource configuration

When you have a gridview bound to an ObjectDataSource, you have to be sure to pass the fields defined in the gridview’s DataKeyNames section to your Delete and Update methods.

Otherwise, you will get an error similar to:

ObjectDataSource 'objDSStatus' could not find a non-generic method 'DeleteContactStatus' that has parameters: ContactStatusId, ContactStatusTypeId.

In this instance I had DataKeyNames=”ContactStatusId, ContactStatusTypeId”, but the DeleteContactStatus method only contained ContactStatusId – the actual primary key.

Also be sure OldValuesParameterFormatString=”{0}”

You don’t need to configure the DeleteParameters in the ObjectDataSource properties as the defined DataKeyNames are passed automatically.

Here is the update code that worked:

  1. Public Sub DeleteContactStatus(_
  2. ByVal ContactStatusId As Integer, _
  3. ByVal ContactStatusTypeId As Integer)
  4.  
  5. Dim arrParams(0) As SqlParameter
  6.  
  7. arrParams(0) = New SqlParameter("@iContactStatusId", ContactStatusId)
  8.  
  9. strSql = "Delete From ContactStatus " & _
  10. "Where ContactStatusId = @iContactStatusId"
  11.  
  12. SqlHelper.ExecuteNonQuery(cn, CommandType.Text, strSql, arrParams)
  13. End Sub

Winter Prey

I missed this one when I first started the series, so it was interesting to find out more about the scars mentioned in a lot of the more recent books.

Winter Prey

Unrecognized tag prefix or device filter

While working with VS 2008, I was getting this warning all through my asp .net code in addition to having no intellisense for any asp controls.

If I added the tag to my child pages, intellisense would come back. I saw a lot of other posts relating to VS 2005 which said to keep the master page open, but that didn’t work.

I had to do the following to get intellisense back:

1. Remove the masterPagefile setting in web.config

2 Delete everything from C:\Documents and Settings\[Username]\ApplicationData\Microsoft\VisualStudio\9.0\ReflectedSchemas

3. Add MasterPageFile=”[master page file name]” to the top of each child page.

Show “Start Page” in VS 2008

View / Other Windows / Start Page

Remove Compress Old Files from Disk Cleanup

An oldie, but a goodie. Whenever I build a new box, I seem to forget all the tweaks I have added.

This tweak gets rid of the annoying Compress old files process when you first start a disk cleanup.

Remove the Compress Old Files Key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches

Here is the detail from Microsoft.

web.config and WebConfigurationManager

The 2.0 framework obsoletes many methods from 1.1.

A line like:

System.Configuration.ConfigurationSettings.AppSettings(“DocumentDirectory”)

results in a compiler warning.

Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'.

The new method is in the System.Web.Configuration namespace and is called WebConfigurationManager.

WebConfigurationManager.AppSettings(“DocumentDirectory”)

CSS items shows up as errors

After I brought a css file in as a theme, I ended up with dozens of errors on a rebuild. Even though HTML/CSS validation was set to Warning in Options, I had to uncheck the option, close the dialog, re-open the dialog, re-check, then re-start VS. CSS issues now no longer prevent a build.

Detailed description and screen shots can be found here:

http://www.west-wind.com/WebLog/posts/194167.aspx

Voltaire

Life is a shipwreck but we must not forget to sing in the lifeboats.

Hidden Prey

The Russians are in town and the welcome is anything but warm.

Hidden Prey

Naked Prey

Drug dealing nuns and a kidnapping gone awry keep Davenport busy.

Naked Prey

Mortal Prey

Clara Rinker is back and the bodies are falling left and right.

Mortal Prey

The Event Marketing Handbook

This book is more relevant for large companies with large budgets. Covers all types of events, where I was looking for more trade show specific information.

The Event Marketing Handbook : Beyond Logistics and Planning

Chosen Prey

A serial killer is loose and Davenport is on the case. Not my favorite genre but hard to put down, nonetheless.

Chosen Prey

« Previous PageNext Page »