Wednesday, October 18, 2006

Create 302 response after moving page

After moving a webpage to another location on your webserver, search engines try to search this page a several times. To avoid this you have to tell the robot that the location is changed, by creating a 302 response:

Response.StatusCode = 302
Response.RedirectLocation = url

Thats all, problem solved.

Wednesday, October 04, 2006

Passing parameters from form to query

I didn't use this idea for my website, but I think it is a very usefull tip voor the MS Access developers among us.
This solution passes values from a MS Access form to a query without defining parameters in de query.

Create an global array:
Global Params(10)

Create a function that returns a value from
Function RtnParams(ParamNum As Integer)
ReturnParam = Para=ms(ParamNum)
End Function


Somewhere in the form (click event button for example) store the values into the array

Params(1) = txtId (from field)

Call in the WHERE-clause of the query the function which returns the right value:
Select * FROM table
WHERE id = ReturnParams(1)


Simple and effective, yet again.

Sunday, October 01, 2006

Dynamically add webusercontrol to webform

On a few pages I dynamically add webusercontrols to a webform. It's very easy.

Drag a panel on your webform, name is default, panel1.
Make a webusercontrol in the directory "webcontrols" in your project, and name it wucmyControl.ascx, for example.

Then use this code in the load event of the form:
Dim myControl = LoadControl("~/webcontrols/wucmyControl.ascx")
'assign a value to the properties of the webcontrol
myControl.property1 = "any value"
myControl.property2 = "any value"
' add the control to the panel control
Panel1.Controls.Add(ThemaControl)

Done!

Using ObjectDataSource in code

There is an easy way to use a objectdatasource in VB.Net code. Drag an objectdatasource control on your webform.
Then, in the page load event, use the following code:

Dim mySource As ObjectDataSource = ObjectDataSource1
Dim result As IEnumerable = mySource.Select()
Dim row As DataRowView

For Each row In result
'your code here
'you can acces any field in a row:
' myString = row("table field name")
Next

Coloring pages Open Season

This new animation movie Open Season shows in cinemas in Holland next week. I am looking for coloring pages of this movie.
Can anyone please help me?

Thanx!

Saturday, September 30, 2006

Google Analytics

It's possible to use Google Analytics for analyzing the traffic onyour blog. Just add a HTML/Javascript page element on your page en paste the javascript Google generates in it. Best is it to put it somewhere at the bottom of your page. It gives great insight in the traffic and it's free.

Look here for Google Analytics.

Friday, September 29, 2006

Query Select random row

I was looking for a way to select a random row from a table, preferably in a stored procedure.
This is the query:

SELECT TOP (1) *
FROM table
ORDER BY NEWID()

Simple and effective!

Google adsense and changes in content

The number of visitors on my site is slowly increasing, so is the number of clicks on the Google ads. Problem is that the number of hits is growing faster than the number of clicks on the ads.
The main reason, I think, is my own content, so I changed the text a little. Google adsense doesn't react immediately, it will take 1 to 2 weeks voor Google to react on the changes.

More info: Google adsense

Coloring pages Cars (Pixar)

I discovered that where just a few good links available with coloring pages of Cars, the new Pixar animation movie.

So I added a few to Kids-n-Fun. So look
here for the coloring pages of Cars!

Create Dynamic headers in ASP.NET 2.0

Kids-n-Fun is a dynamic site. All content is stored in a database. I have some code (VB.Net) to create the content tags in the header dynamically.

If you using a Masterpage use this in the load event:
Dim myPage as new Page
Dim myHTMLHead as new HtmlHead
Dim myHTMLMeta as new HTMLMeta

myPage = thisPage
myHTMLHead =CType(myPage.Master.FindControl("MasterHeader"), HtmlHead)
myHTMLMeta.Name = "description"
myHTMLMeta.Content = "your description"
myHTMLHead.Controls.Add(myHTMLMeta)

myHTMLMeta.Name = "keywords"
myHTMLMeta.Content = "your keywords"
myHTMLHead.Controls.Add(myHTMLMeta)

If you don't use master pages (you should!) use this code instead:

myHTMLHead=CType(myPage.Header, HtmlHead)

The rest of the code is the same.

First blog

Well, welcome to my blog. I have created this blog to write about my experiences creating a brand new website Kids-n-Fun. This blog is about the things I discover along the way, about content, ASP.Net 2.0, search engine optimalisation, Google Adsense and so on.

Kids-n-Fun is a (dutch) website for kids. I have started with coloring pages, and create much more the coming winter. Pages voor crafts, recipes kids can make themselves. After that there will be a special corner voor parents, but more about that in the near future.

Enjoy!