Solution to dasBlog "Remember My Login" Not Working#

A while ago, maybe 3 months, my blog stopped remembering my login.  When I login I can click to have it remember my login, and thus when I return to the site I don't have to login every time.

Well I finally arrived at the problem. 

In IIS settings for the website, under the ASP.NET tab, if you click the "Edit Configuration" button, and then the authentication tab, you have the option to set the expiration length for the cookie, which was set to 1 hour.

I changed it to a larger value, restarted the IIS processes, and it appears to be working great now!

Categories: Blogging | Programming | ASP.Net | dasBlog | IIS
Friday, September 29, 2006 5:00:30 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

A Look Into Google's Agile Development#

Here is a very interesting article:

http://steve-yegge.blogspot.com/2006/09/good-agile-bad-agile_27.html

Google let's their employees work on whatever they want, gives amazing benefits (meals, gift certificates, stock), requires 20% of a persons time to be spent on their own side projects, doesn't have due dates, and much more. 

Sounds pretty cool! ;)

Categories: Programming
Thursday, September 28, 2006 3:47:01 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

VS.Net Macro to Narrow VB.Net Method Signatures and Function Calls#

Lately I have been doing some refactoring of code as I go through it.

Trying to name variables correctly, breaking up long methods, trying to adhere to some coding standards.

One way that I have been employing to clean up code is to convert very long method signatures, or calls to methods with many parameters from LONG single line entities to shorter multi-line blocks.

This is simple, but tedious.  So I wrote a VS.Net macro to do it for me.

Simply copy and paste the macro code (paste into wordpad first to get rid of the missing newline problem) at the bottom of this article into a macro.  Then all you have to do is highlight the entire row you want to "narrow", and run the macro.  You can always Cntl+z out of it if you want to undo the changes.

The results are good!  The following are examples of a long method signature, and a call to a method with a lot of arguments, and then the refactored results.

'*** Long method signature
Public Function ActivitySave(ByVal Activity As MyNamespace.Business.Equipment.Activity, ByVal StartTime As DateTime, ByVal EndTime As DateTime, ByVal StatusOverride As System.Nullable(Of MyNamespace.Business.Data.Criteria.Equipment.ActivityStatusEnum), ByVal Clerk As Integer) As Integer

'*** long method call
ActivityID = MainActivity.ActivitySave(Activity.ActivityID, Activity.Status, Activity.PurposeNotes, Activity.JobIndex, Activity.CategoryID, Activity.RequestedStartDate, Activity.RequestedEndDate, Activity.EquipmentID, Activity.PlanStartDate, Activity.PlanEndDate, Activity.ActualStartDate, Activity.ActualEndDate, Activity.DiscountScheduleID, Activity.DiscountOffset, Activity.CodeID, Activity.RentalRate, Activity.RowVersion, Clerk)

Here is the result of the refactoring:

'*** Refactored long method signature
Public Function ActivitySave(ByVal Activity As MyNamespace.Business.Equipment.Activity, _
ByVal StartTime As DateTime, _
ByVal EndTime As DateTime, _
ByVal StatusOverride As System.Nullable(Of MyNamespace.Business.Data.Criteria.Equipment.ActivityStatusEnum), _
ByVal Clerk As Integer) As Integer

'*** Refactored long call
ActivityID = MainActivity.ActivitySave(Activity.ActivityID, _
Activity.Status, _
Activity.PurposeNotes, _
Activity.JobIndex, _
Activity.CategoryID, _
Activity.RequestedStartDate, _
Activity.RequestedEndDate, _
Activity.EquipmentID, _
Activity.PlanStartDate, _
Activity.PlanEndDate, _
Activity.ActualStartDate, _
Activity.ActualEndDate, _
Activity.DiscountScheduleID, _
Activity.DiscountOffset, _
Activity.CodeID, _
Activity.RentalRate, _
Activity.RowVersion, _
Clerk)

 

Here is the macro.

 Public Sub NarrowMethodsAndCalls()
'Create an Undo context object so all the changes can be
'undone by CTRL+Z
Dim oUnDo As UndoContext = DTE.UndoContext

'Supress the User Interface. This will make it run faster
'and make all the changes appear once
DTE.SuppressUI = True
Try


Dim oTextSelection As TextSelection = DTE.ActiveWindow.Selection
Dim sOrigText As String = oTextSelection.Text

Dim RegExp As New System.Text.RegularExpressions.Regex("([ .=_a-zA-Z0-9]*)\(")
Dim Match As System.Text.RegularExpressions.Match = RegExp.Match(sOrigText)
If Match.Success Then
Dim sMethod As String = Match.ToString
Dim sParametersAndReturn() As String = sOrigText.Replace(sMethod, "").Split(",")
Dim sFirstLineWhiteSpace As String
Dim sb As New System.Text.StringBuilder
sb.Append(" ", Trim(sMethod).Length)
sFirstLineWhiteSpace = sb.ToString

'*** redo the first line
oTextSelection.Text = sMethod & sParametersAndReturn(0) & ", _"
oTextSelection.NewLine()
oTextSelection.Text = sFirstLineWhiteSpace

For i As Integer = 1 To sParametersAndReturn.Length - 2
oTextSelection.Text = Trim(sParametersAndReturn(i)) & ", _"
oTextSelection.NewLine()
Next
oTextSelection.Text = Trim(sParametersAndReturn(sParametersAndReturn.Length - 1))
oTextSelection.NewLine()



Else
MsgBox("failed to find function regexp match")
End If
Catch ex As Exception
MsgBox("Error: " & ex.ToString)
Finally

'If an error occured, then need to make sure that the undo context is cleaned up.
'Otherwise, the editor can be left in a perpetual undo context
If oUnDo.IsOpen Then
oUnDo.Close()
End If

DTE.SuppressUI = False
End Try

End Sub
Categories: .Net | VB.Net | VS.Net | Macros
Wednesday, September 27, 2006 10:52:05 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

SmartNavigation with Metabuilders Combobox#

I ran into a little problem trying to integrate Metabuilders combobox into an asp.net web app I am creating.

The problem was that the onload event handler was not properly firing when smartNav was turned on.

The "InitScript" was as follows:

if ( typeof( window.addEventListener ) != "undefined" ) {
    window.addEventListener("load", ComboBox_Init, false);
    alert('case 1');
} else if ( typeof( window.attachEvent ) != "undefined" ) {
    window.attachEvent("onload", ComboBox_Init);
} else {
    ComboBox_Init();

}

Well when you are using smartNav, the window.onload event is only fired the first time you reach the page.  So I used this bit of C# in the control to get it to work.

String initScript = resources.GetString("InitScript");
if (this.Page.SmartNavigation)
{
this.Page.RegisterStartupScript("MetaBuilders.WebControls.ComboBox Init with Smartnav", "<script>ComboBox_Init();</script>");
}
else
{
this.Page.RegisterStartupScript("MetaBuilders.WebControls.ComboBox Init", initScript);
}

 

Categories: Programming | .Net | ASP.Net | C# | Javascript
Monday, September 25, 2006 8:06:55 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

Generating Web Traffic#

Here is a pretty good list of articles that discuss ways to generate web traffic for your site:

http://www.copyblogger.com/increase-web-traffic/

 

Categories: Blogging
Thursday, September 21, 2006 11:10:33 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Checking for JavaScript Variable Definitions#

In some cases you need to be able to check if a variable has been defined, and if it has a value.

I recently had a problem where I needed a function to check if a variable had been defined, and if not, to return a default value "1".

The following code will check if the variable is defined, and if it is, it will also check and make sure that it isn't null, before returning the value.

 

function GetDefaultModuleId(){
    if (typeof(csDefaultModule) == "undefined"){                            
        return "1";
    }else{
        if (csDefaultModule == null){
            return "1";
        }else{
            return csDefaultModule;
        }                    
    }
}

 

Categories: Programming | Javascript
Tuesday, September 19, 2006 2:21:26 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Free Utilities#

Here is another list of some great freeware products, free browsers, anti-virus, anti-spyware etc.

http://www.techsupportalert.com/best_46_free_utilities.htm#9

Categories: Software | Utilities
Monday, September 18, 2006 2:51:20 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Extending the Atlast AutoComplete Extender#

I have been looking at the new "Atlas" controls, which MS has brilliantly (sarcasm) decided to rename "ASP.NET AJAX".

The one control I have been most interested in is the autocomplete extender.

I want to use something like this, not to help populate a textox, but instead to allow the user to type a few characters in to narrow down the list of options, rather than showing them a dropdown of 10,000 items.

In otherwords, when they are done with the control, I don't want the text in the textbox, I want the database ID value behind it, and i also don't want to let them type in just anything they want, but rather limit their options to what is in the autocomplete options.

I found another blog post where someone is extending the autocomplete behavior:

http://aspadvice.com/blogs/garbin/archive/2006/01/02/14518.aspx

 

Categories: Programming | .Net | ASP.Net
Monday, September 18, 2006 1:39:31 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Debug = true in web.config files#
Categories: Programming | .Net | ASP.Net
Thursday, September 14, 2006 2:22:27 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Performance of Web Services / Remoting / Enterprise Services#

I had previously read and heard in presentations by Rocky Lhotka that performance comparisons between Web Services and Remoting showed that they were basically the same, and that when talking about RPC protocols ES killed them both so badly (order of magnitude) that it wasn't worth fretting over the small diff between WS and remoting.

Rocky kinda explains this position in this post:
http://www.lhotka.net/weblog/RemotingVsWebServicesVsESCOMDCOM.aspx

However, I actually tracked down the white paper on Microsofts website:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebsrv/html/asmxremotesperf.asp

Much to my suprise the giant performance improvement when using ES was only seen when calling empty functions.  In otherwords, it was basically a test of the transport.  Some "real world" tests showed ES performing faster than most other methods, but sometimes something like Remoting TCP Binary would outperform it as well.

In the tests that actually did something, the performance across the board was usually fairly comperable.  I guess this makes sense.  If you liken the round trip of an RPC call to a person going on a business trip, the speed of the airplane is less important that the time it takes the person to do the job at the end of the trip.  So even if your plane takes 3 hours instead of 2 hours, if your going to be staying for a week then that 1 hour isn't a big deal.

The major conclusion is to not pass datasets.  Datasets are serialized as XML even if you are using the binary serializer.  I have posted some stuff on this topic as well on my blog so you can search for it if you want. 

Categories: Programming | .Net | .Net Framework | Architecture | WebServices
Thursday, September 14, 2006 9:12:30 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

"Updating" a SQL Inner Join Query#

I frequently get asked how you can update a join statement in SQL.  Of course, the UPDATE syntax doesn't allow for you do actually perform an update directly against a JOIN statement, but there are some things you can do to work around this problem.

Probably the best way is to do the update like the example below:

UPDATE Job_Opportunities
SET AwardedId = 1
WHERE JobOpportunityId = (
    SELECT JO.JobOpportunityId
    FROM Job_Opportunities JO
    INNER JOIN
    Job_results JobResults
    ON BO.JobOpportunityID = BR.Job_id
    AND JR.is_us = 1
    AND JR.rank = 1
    AND JO.JobOpportunityId = Job_Opportunities.JobOpportunityId
)

This example is updating the Job_Opportunities table, but in the WHERE clause we can use a join to make sure that the only rows that are updated are those that meet the criteria of the join.
Categories: Programming | Database
Wednesday, September 13, 2006 2:09:02 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Data Driven Checkbox (Horizontal) Lists#

This control is pretty cool.  It makes it pretty easy to databind data into a list of checkboxes.

http://developer.coreweb.com/articles/Default6.aspx

Categories: Programming | .Net | ASP.Net | DataBinding
Wednesday, September 06, 2006 5:54:56 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Rocky Lhotka and Csla.Net/Asp.Net on DnrTV#

Rochy Lhotka appeared again on DNR-TV for 2 more segments focusing on CSLA in ASP.Net and WebServices:

http://www.dnrtv.com/default.aspx?showID=32

http://www.dnrtv.com/default.aspx?showID=33

Having successfully completed a CSLA.Net project for Wilson Sporting Goods I am interested to see what is different in the web side vs the winform side.

Categories: Programming | .Net | ASP.Net | DataBinding
Wednesday, September 06, 2006 4:39:48 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Checking an objects type or implemented interfaces#

A common thing people might want to do is check if a object is a certain type, or inherits a type, or implements a type.

This can be done in VB.Net with the following code:

TypeOf someObject Is ClassName

This works for inheritance heirarchy as well as checking for interface implementation.

Here is a sample app showing it in practice.

imports Microsoft.VisualBasic
imports System
Imports System.Collections.Generic

public module MyModule
    sub Main
dim o as new subclass
        WL(typeof o is subclass)
        WL(typeof o is baseclass)
        WL(typeof o is IWhatever)
        RL()
    end sub

    #region "Helper methods"

    sub WL(text as object)
        Console.WriteLine(text)
    end sub

    sub WL(text as object, paramarray args as object())
        Console.WriteLine(text.ToString(), args)
    end sub
        
    sub RL()
        Console.ReadLine()
    end sub
    
    sub Break()
        System.Diagnostics.Debugger.Break()
    end sub

#end region

end module


public interface IWhatever
end interface
public class BaseClass

end class

public class SubClass
inherits BaseClass
implements IWhatever

end class
Categories: Programming | .Net | VB.Net
Wednesday, September 06, 2006 4:35:02 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

SQL Server Decimal/Money/Float datatypes#

When dealing with money, or numbers, sql server provides a few different datatypes: Decimal, Money, Float among others.

The main difference is that Decimal and Money datatypes are "exact", as opposed to Float which is a "Floating Point Representation".

When dealing with Floats, you can get some odd mathematical results:
http://www.chrismay.org/2005/09/29/BinaryRepresentationOfDecimalValues.aspx

e.g.
0.4 - 0.1 = 0.30000000000000000000004
1.4-1.1 = 0.29999999999999999999998

So when a number is going to represent money, you should use the Decimal or Money datatypes.  Money is (19,4) which means 19 total digits, 4 of which are right of the decimal point.  Decimal can be setup however you want, like Decimal(10,2).

SmallMoney can also be used, which can represent money values under 1,000,000 w/ 4 decimal places.

 

Categories: Programming | Database | SQL Server
Wednesday, September 06, 2006 9:40:48 AM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

PostBackUrl And SmartNavigation Bug?#
I have a page with SmartNav, that contains a linkbutton with a
PostBackUrl.

I have found that the page that is the target of the PostBackUrl will
have it's postback property fired 2 times, and unfortunately, the 2nd
time it is fired the "PreviousPage" is set to Nothing.

I have posted a few places to see if someone from MS can confirm this is a bug, but  I am betting they are going to tell me to not use smartnav.

Categories: Programming | .Net | ASP.Net
Thursday, August 31, 2006 10:30:38 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Rutgers Tennis#

A good friend of mine and a guy I hit with all the time played at Rutgers.  Now it looks like they are going to cancel the program.

A website has been created to raise some money to help their program.

http://saverutgerstennis.org/

Categories: Thoughts
Wednesday, August 30, 2006 8:28:00 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

SQL Server Merge Replication#

One of the challenges in doing merge replication in SQL Server is dealing with IDENTITY columns.

One of the tricks you can use is "automatic identity range management". 

Basically you tell DB 1 to start at seed 1 and DB 2 to seed at 20,000, and when DB 1 reaches 16,000 or DB 2 reaches 36,000 it will reset those seeds to 40,000 and 60,000.

http://msdn2.microsoft.com/en-us/library/ms152543.aspx

http://msdn2.microsoft.com/en-us/library/ms146907.aspx

It appears to work well.

Categories: Programming | Database | SQL Server
Tuesday, August 29, 2006 2:55:35 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Getting IE To Print Backgrounds And Cell Colors#

I was having a small problem getting some reports to print the way I wanted.

I turns out that to get the table cells colored backgrounds to print, click on the browser’s Tools menu. Select Internet Options, then click on the Advanced tab. Scroll down to find the Printing heading and check the box called Print Background Colors and Images. This setting affects both page backgrounds and table cell backgrounds.

Categories: Programming | HTML
Saturday, August 26, 2006 6:57:53 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Using XSD.exe#

.Net has a tool called the XML Schema Definition Tool (XSD.EXE) which can turn XSD schemas into classes.  Also, it will try to make it so those classes will conform to the schema when serialized as XML.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconxmlschemadefinitiontoolxsdexe.asp

xsd.exe pathToXSD.xsd /classes /language:VB /outputdir:C:\output

You can then serialize and deserialize the object into/from XML.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassTopic.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassDeserializeTopic.asp

 

 

Categories: Programming | .Net | XML
Friday, August 25, 2006 3:10:35 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

All content © 2010, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<September 2006>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.3.9074.18820

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: