This tip is how to use a linkbutton inside a frame . It’s harder than it sounds since the linkbutton doesn’t have a target property.
ASP.NET linkbutton in a frame
August 1, 2007 by aspcodeASP tip of the day
June 24, 2007 by aspcodeThe code we use presents a random tip by using ASP and a little trickery. In addition, our code never presents the same tip twice until all the tips have been presented.
Here’s how we do it…
First, let’s look at the structure of the SQL Server table that holds all the tips (KB).
ID int
Summary varchar(255)
FileName varchar(255)
Presented bit
ID is the primary key for the table and is used to reference each tip. The Summary column contains text that is used to summarize the tip and is what we show the user for a short description of the tip. FileName holds the actual file name of the page for the tip. The Presented column is either 1 or 0, indicating if the tip has already been presented.
The overall structure of the ASP code used to display the tips has several steps:
setup the db connection
’setup the db connection
Set dbTip = Server.CreateObject(”ADODB.Connection”)
dbTip.Open sDSN
Initialize the VBScript number randomizer
‘Init the number randomizer
Randomize
Get the total number of tips that have not been presented
‘get the total number of tips
sSQL = “SELECT Count(ID) AS CountOfTipID FROM KB WHERE Presented = 0″
Set rsTip = dbTip.Execute(sSQL)
iTipUpperBounds = rsTip(”CountOfTipID”)
If all the tips have been presented, reset the presented flag on all the tips
‘make sure we have records to present
If iTipUpperBounds = 0 Then
‘all the records have been presented…
‘we need to clear the dirty flag
sSQL = “UPDATE KB SET Presented = 0″
dbTip.Execute(sSQL)
‘get the total number of tips…again, now that we’ve cleared dirty flag
sSQL = “SELECT Count(ID) AS CountOfTipID FROM KB”
Set rsTip = dbTip.Execute(sSQL)
iTipUpperBounds = rsTip(”CountOfTipID”)
End
If
Pick a random number between 1 and the total number of tips that have not been presented
‘pick a random tip
iTipNumber = Int(((iTipUpperBounds -1) – 0 + 1) * Rnd + 0)
Get all the tips that have not been presented
‘get the tips
sSQL = “SELECT ID, Summary, FileName FROM KB WHERE Presented=0″
Set rsTip = dbTip.Execute(sSQL)
Move the cursor to the random number using the Move method.
’select the random tip
rsTip.Move iTipNumber
Read the record and present the data
” target=”_top”>Click
here for the details…
Update the record to indicate that it’s been presented
‘turn the presented flag on for the record
sSQL = “UPDATE KB SET Presented = 1 WHERE ID = ” & rsTip(”KBID”)
dbTip.Execute(sSQL)
Clean up
‘clean up recordset
rsTip.Close
Set rsTip = Nothing
dbTip.Close
Set dbTip = Nothing
Below, is a working example…referesh the page to see the summary of a new tip.
Consultant Personalities – ASP.NET Style
June 12, 2007 by aspcodeHilarious, even if you don’t know ASP.NET.
Even funnier if you do know ASP.NET.
How to load a SQL file info Postgresql
June 11, 2007 by aspcodeTherefore it might give you some trouble when trying to use them from the pgAdmin interface.
However it’s not all that hard
load a SQL file info Postgresql
ASP.NET and paypal shop
June 4, 2007 by aspcodeCreate our own paypal shop using asp.net. Described in this article serie here
MySQL and ADO.NET Additional information: That assembly does not allow partially trusted callers
May 30, 2007 by aspcodeThe trouble of getting MySQL to funciton in medium trust is not an easy one to solve. This article talks about that
Download Etchy font
May 4, 2007 by aspcode
These characters are shown in 28pt. Just hover a letter/number to see it in 72pt
This is a very nice font, Etchy, which you can download for free at the link above,
Send mail with ASP and JMail
May 3, 2007 by aspcodeHere is a ProperCase function in C#
It’s good I guess not to use the VisualBasic runtime , but be sure to read the comment where using the CurrentCulture.TextInfo.ToTitleCase is also decribed.
AdMentor PRO 5.0 is released
April 25, 2007 by aspcodeASP file handling functions
April 4, 2007 by aspcodeHere is a nice list of all things regarding file handling in ASP (i.e read, append, write, check if exists) in ASP. All explained and code samples as well.
