Thursday, March 29, 2012

OnServerClick problems

Hello,

When i use the OnServerClick method within my anchor control it gives an "error on page" when i click the link.

This is my this anchor code

<a
id="Anchor1"
OnServerClick="Anchor1_Click"
runat="server"
Row Count
</a

And this is the sub it refers to

Sub Anchor1_Click(Source as Object, E as EventArgs)
Anchor1.InnerHtml = "Table 1: " & Table1.Rows.Count _
& " rows - Table 2: " & Table2.Rows.Count & " rows"
End Sub

Why is isn't this working?

Thanks in advance

Paul WiggersThere is no OnServerClick, you have to use OnClick for server side sub calls!
ok i have changed the OnServerClick to OnClick. But right now the text between the <a></a> tags isn't a link anymore, it's just plain text.

What to do about that?

And can you please explain why there isn't an OnServerClick? I thought that was used when you posted towards the same page.

TIA

Paul Wiggers
OnServerClick should work Ok as you're using a HtmlControls.HtmlAnchor object/class rather than a web control.

Is your <a tag inside <form runat="server" tags? If not then this could be your problem.
OOps, I thought he is using server side control, Yes, it should work as he said!
great, thanks for your help. Works perfectly now.
Still don't understand why I couldn't think of that. ah well, learn something new everyday ;)

thanks again

0 comments:

Post a Comment