Hyperlink Repositions to top of screen

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Hyperlink...
<asp:HyperLink id="HyperLink1" runat="server" CssClass="LinkButton"
href="#">Add Item</asp:HyperLink></TD>

Which when clicks calls a javascript function AddItem. This linkage is
addedin the form_load of the page thus: (simple example)
HyperLink1.Attributes.Add("onClick", "addItem('" & HyperLink1.ClientID &
"','" & "123" & "','" & "321" & "')")


(
this gets written to the browser as
<a id="HyperLink1" class="LinkButton" href="#"
onClick="addItem('HyperLink1','123','321')">Add Item</a>
)

This does not produce a postback, which is good, but alas does reposition
the page the the top, which is bad.

I have a feeling that it's something to do with the href="#" in the
Hyperlink definition, but am unsure of what to use instead.

Any help would be appreciated, really.. any...
Many thanks
 
href="#" means navigate to bookmark (unnamed). you can put bookmarks on
the page and jump to them or include in a url.

a common alternative is href="javascript:void(null);"


-- bruce (sqlwork.com)
 
Back
Top