Disable the postback on an

前端 未结 17 1532
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 00:18

I have an ASP.NET linkbutton control on my form. I would like to use it for javascript on the client side and prevent it from posting back to the server. (I\'d like to use t

17条回答
  •  既然无缘
    2020-12-03 00:51

    This may sound like an unhelpful answer ... But why are you using a LinkButton for something purely client-side? Use a standard HTML anchor tag and set its onclick action to your Javascript.

    If you need the server to generate the text of that link, then use an asp:Label as the content between the anchor's start and end tags.

    If you need to dynamically change the script behavior based on server-side code, consider asp:Literal as a technique.

    But unless you're doing server-side activity from the Click event of the LinkButton, there just doesn't seem to be much point to using it here.

提交回复
热议问题