Thursday, February 22, 2007

Registry-less Programmer's Notepad 2

Programmer's Notepad 2 can be made to run without using the registry (i.e. make it portable, so you can use it on a removable hard drive / pen drive), but only with a development build. All it needs is a config.xml in its directory containing the following:

<config>
  <userSettings path="settings" />
  <storeType value="Xml" />
</config>

Alternatively, this batch file can be used to create the file and copy over your settings. Create a batch file e.g. pn2local.cmd and paste in the following code:

@echo off
if exist config.xml goto copysettings
echo ^<config^> > config.xml
echo    ^<userSettings path="settings" ^/^> >> config.xml
echo    ^<storeType value="Xml" ^/^> >> config.xml
echo ^<^/config^> >> config.xml
:copysettings
md settings
xcopy "%AppData%\Echo Software\PN2\*.*" settings\ /D /Q

Tuesday, February 20, 2007

Remove multiple options with removeOption

removeOption, a plugin available along with my other select box manipulation ones can now take a regular expression as the parameter. This can be used to remove more than one option in one go (or even all of them).

Wednesday, February 14, 2007

Select box manipulation with jQuery

If you read the jQuery mailing list, you may be aware that I have updated my plugins for working with select boxes. Summary of changes:

  • addOption replaces any options with the same value (so think of it as an add/replace options plugin
  • selectOptions selected options in addition to what was already selected, but there is now an option for it not to do this
  • There are two new methods:
    • copyOptions which is for copying options between select boxes
    • ajaxAddOption allows you to add options via AJAX (i.e. could be used for create options dynamically from a server script)

Monday, February 05, 2007

Adding a WebControl before or after another one (ASP.NET C#)

ASP.NET does not directly allow you to add a WebControl after another one (i.e. you can't do MyRepeater.AddAfter(MyLiteral) to add MyLiteral after MyRepeater. These two simple functions allow you to do just that:

public void AddControlBefore(Control beforeControl, Control controlToAdd)
{
 Control container = beforeControl.NamingContainer as Control;
 container.Controls.AddAt(container.Controls.IndexOf(beforeControl), controlToAdd);
}
  
public void AddControlAfter(Control afterControl, Control controlToAdd)
{
 Control container = afterControl.NamingContainer as Control;
 container.Controls.AddAt(container.Controls.IndexOf(afterControl) + 1, controlToAdd);
}