Tuesday, October 27, 2009

Customize a NewForm.aspx to accept Query Parameters

Works on WSS 3.0 and MOSS 2007

This post will show you to create a hyperlink in a Data View Web Part (DVWP) that open’s a customized NewForm.aspx. When the NewForm.aspx opens, it’ll have some of the required inputs already filled out for you. We’ll set this magic up by using DVWP and parameters passed from the DVWP to the NewForm.aspx.

I need to show you how I have my lists setup first, so let’s dive into that for a minute. I have two lists setup: 1. Calendar with two custom columns. These two columns are Job # and Job Name. The rest is default or whatever you’d like to have. The next list I have is a Tasks list that has these two custom columns as well. Here are some screen shots:



You should take notice that I’ve required Job # to be inputted on each form. This is a must because it’s our primary key, if you will. This is going to be used for filtering later on, so it’s important.

Now that we have those lists setup we can now create our custom dashboard that allows hyperlink filtering and our magical custom newform.aspx. Fire up sharepoint designer and create a new aspx page. Add a webpart zone to your page, so we’ll have a spot to place our DVWP. Now we’ll want to click on Data View, Insert Data View. Inside our Data Source Library, we’ll highlight the Calendar. Then you’ll select show data. This will allow us to select the rows we’d like to appear in our DVWP. I usually only select one row and then click the Insert Selected Fields As: Multiple Item View. After I get the DVWP to show up on my page, then I’ll choose to edit the columns as they seem fit. SAVE YOUR WORK! We’ll call this page: Dashboard Right now, we want to see only the Job # and Job Name fields from the calendar list. Now we need to add a column to the DVWP. This will provide us a place for an additional hyperlink to our Custom NewForm.aspx. In the new column, pick any row that has a job # and then type “Add Task…”. If you have done it right, it’ll populate your entire DVWP.

Here’s a quick glance at what it should look like:


Once you get this setup how you like it, we’ll need to add two parameters to our DVWP. When you highlight the DVWP, you’ll see a chevron on the right of it. That is a menu for Common Data View Tasks. Listed inside this menu is our parameters section. Open that and add two Query Strings. Here is a photo to guide you along:


We’ll need these in order to carry information from our Dashboard to our CustomNewForm.

We now need to create another new aspx page and customize it. This will be our custom NewForm.aspx. I called it AddTask.aspx, but you certainly can make it whatever you like. I saved my page in the same place where the NewForm.aspx is for the Tasks list that I’m using. Once we have added a new web part zone to our page, we can now add a custom form. If you follow the same steps as above to add a new DVWP, you’ll be fine. There are a few differences from what we did before though. You will add the DVWP as a New Item Form instead of Multiple Item View. Also you’ll want to make sure the DVWP is for the Tasks list and not the Calendar. You’ll also want to customize the inputs as you seem fit. Be sure to include any required fields on your Tasks list on your AddTask.aspx page. Also make sure that Job # and Job Name are inputs on your AddTask.aspx page. Ok once that has been setup, now we can get down to the magic.

We’ll now delete both of the text boxes for Job # and Job Name. We are going to replace them with our own. Highlight the form where you’d like for them to show up, and then select Insert, ASP.Net Controls, Text Box. We have to do that because when using the DVWP for a new item form, it wouldn’t allow me to alter the Value property. When I do it this way with our own ASP.Net control, I’m able to. Now we need to make these text boxes reference our Tasks list. There will be a little chevron on each text box. Clicking that will give us the options we need. Change the data field for both to relate to the field you need. i.e. Job # = Job #, you get the idea. Now switch to code view and drop a few custom lines of magic. First we need to add our Query Strings as a parameter for our page to use. This is the code we need to add:

<ParameterBinding Name="JobNum" Location="QueryString(JobNum)" DefaultValue="Please Type a Job Num" />
<ParameterBinding Name="JobName" Location="QueryString(JobName)" DefaultValue="Please Type a Job Name" />


You’ll need to search the code view using:

<ParameterBinding Name

Just paste the code provided above in the <ParameterBinding Name section. I usually just search the code view for <ParameterBinding Name using ctrl+f. Put these two lines of code below everything else in this section. Now we need to add these two lines in the <xsl:stylesheet section as a parameter. Using the same logic as above, I searched the code view for <xsl:param This can be a bit convoluted because there are many <xsl:param under many other xsl:template names. I added mine directly under the xsl:stylesheet. You’ll find a few parameters there, so add them accordingly. Here is the code that you need to add:

<xsl:param name="JobNum" />
<xsl:param name="JobName" />


Now we need to add a value to our customized text boxes. Again search the code for Job Name. Below that is the text box code. It begins with:

<asp:TextBox runat="server"


We need to modify this line and add one attribute:


Your text box code should look like this… I suggest only to add the line of code above and not copy what is listed below!


<asp:TextBox runat="server" id="ff10{$Pos}" value="{$JobName}" text="{@Job_x0020_Name}" __designer:bind="{ddwrt:DataBind('i',concat('ff10',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Job_x0020_Name')}" />


Now change the Job # text box the same way except we’ll add this line of code instead:



SAVE YOUR WORK! We need to add one last thing to our Dashboard page and that’s our magic hyperlink! With that page open in Design View, highlight the “Add Task…” text that we added above. Right click and select hyperlink. We have to link this page to our AddTask form and add our parameters. Our link should look like this:


Save this page on final time and cross your fingers because I think we are ready to test this baby out! Open your Dashboard page and click Add Task… This should open your AddTask.aspx page and automagically fill out Job # and Job Name.

If you like this or need some clarification, please feel free to drop me a comment.


Bookmark and Share

Wednesday, July 29, 2009

Vista SP2 x32 bit vs. Win 7 x64 bit

I followed the same steps as TK did in his original post.  I really wanted to see which is better.  So, I set out on the absurd task of formatting my box just to install an O.S. and run tests.  I only call it absurd because all of my settings take forever to get back in place.

You don’t have to worry, pc images are your friend.  After creating a TESTED image, I then formatted my box.  Once I had Vista back on my machine, I realized why I went for Win 7 even though it was still in BETA at the time. 

I used the same benchmarking tool as did TK: Passmark Performance Test.  Here are the results:

  1. Vista SP2 x32 bit Passmark Rating - 1259.2
  2. Win 7 x64 bit Passmark Rating - 1352.0

It wasn’t even close as I expected.  After all, I am running a x64 bit architecture vs. a x32 bit.  To make things a bit more fair, I’m going to run through the whole process again but this time, I will include: XP SP3 x32 bit, Vista x64 bit, and Win 7 x32 bit.  I know, I know, but what about XP x64 bit… I just wont go there.

If you clicked the links to view the results, you may have noticed exactly why Win 7 beat Vista here… If not, check the Passmark ratings for Total RAM.  That should give you a clear reason why Win 7 x64 bit won.  If you were wondering, I’ve linked a Belarc Report so you can view the hardware that I am using for these tests.

Sunday, July 26, 2009

TK posts big!

Check out the work a great friend of mine is doing:


Big ups to TK and getting accurate results out to the web.  He also runs tests against the new Win7 and Vista.  You can check out his latest post @


I can’t stress the importance enough about these tests.  Allowing the default O.S. to be tested in this unbiased manner proves valuable for anyone who owns a computer.  If you’d like more details about how these tests were conducted, comment till your fingers bleed.  It’s definitely worth it IMHO

Wednesday, July 8, 2009

Creating custom background for Twitter using Twitbacks.com

Bookmark and Share

Thanks for the great link Stacy Kinney. Twitbacks looked interesting so I obliged. The whole process took about 2 minutes from start to finish. The outcome was better than what I thought it would be. My Twitter background looks nice now . The ability to create a custom message on the left side is neat. Also, you are able to fill out a message (up to 250 characters) and upload a logo/picture (2 MB limit) of whatever you like. The background you can also customize with your own image or select from one of the templates. This service is completely free unless you want to add more functionality.

Some of the options that cost money are:
  1. Removing the twitbacks logo
  2. Adding promotion services to your Twitter account – More Info
Twitbacks does say that there will always be a free service, let’s see what kind of innovations they can bring to the table. So far I really only see services that are geared towards businesses that are using Twitter as a marketing platform. All in all, this was completely worth my time and yours too.