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!