Counting Clicks

B

Bart

Hi all,

A customer of mine has an page with a datagridcontrol..

The grid contains a description field of a pdf document and a
HyperlinkColumn to the actual pdf file..(the location is read from a
database)

Now my client asks if its possible to count how many times a pdf is
displayed in other words every time a user clicks a link a counter has be
updates. Can I link a command to a hyperLinkColumn wich fire's a function I
created??

thks,

Bart
 
E

Elton Wang

Hi Bart,

Currently, when HyperlinkColumn is clicked, what do you
do, directly shows pdf file or some thing else?

Elton Wang
 
B

Bart

I directly show the PDF file thru the DataNavigateUrlField field wich is
bound to a field in the DB

rgds,

Bart
 
B

Bart

I directly show the PDF file thru the DataNavigateUrlField field wich is
bound to a field in the DB

rgds,

Bart
 
K

Ken Cox [Microsoft MVP]

What about using a Linkbutton so you can bump the counter during its click
event?

Private Sub Page_Load _
(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
If Not IsNothing(Application("clicks")) Then
Label1.Text = "Clicks=" & Application("clicks").ToString
End If
End Sub

Private Sub LinkButton1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles LinkButton1.Click
Application.Lock()
Application("clicks") = Application("clicks") + 1
Application.UnLock()
Response.ContentType = "application/PDF"
Response.AppendHeader("content-disposition", _
"attachment:filename=test.pdf")
Response.WriteFile(Server.MapPath("MiniReader.pdf"))
End Sub

<form id="Form1" method="post" runat="server">
<p>
<asp:linkbutton id="LinkButton1"
runat="server">LinkButton</asp:linkbutton></p>
<p>
<asp:label id="Label1" runat="server"></asp:label></p>
</form>

Ken
Microsoft MVP [ASP.NET]
Toronto
 
E

Elton Wang

Hi Bart,

Another way is to build a new page, e.g. pdf.aspx. And
change datagrid DataNavigateUrl Field from pdfUrl
to "pdf.aspx?url=" + pdfUrl.

In pdf.aspx Page_Load, using following code:

if (this.Request.QueryString.Get("Url") != null)
{
string url = Request.QueryString.Get("Url");
if (!url.Equals(""))
{
// count click
this.Response.Redirect(url);
}
}

Elton Wang
(e-mail address removed)
-----Original Message-----
I directly show the PDF file thru the
DataNavigateUrlField field wich is
 
B

Bart

that's a great idea.. I'll give that a try


Hi Bart,

Another way is to build a new page, e.g. pdf.aspx. And
change datagrid DataNavigateUrl Field from pdfUrl
to "pdf.aspx?url=" + pdfUrl.

In pdf.aspx Page_Load, using following code:

if (this.Request.QueryString.Get("Url") != null)
{
string url = Request.QueryString.Get("Url");
if (!url.Equals(""))
{
// count click
this.Response.Redirect(url);
}
}

Elton Wang
(e-mail address removed)
DataNavigateUrlField field wich is
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top