Tiago Silva
Tiago Silva

Reputation: 254

How to change attributes in a LinkButton Href asp.net

Hello how can i change attributes inside a LinkButton, on button click event.

This is an example:

<asp:Label runat="server" ID="LblBarcode" Font-Bold="true"></asp:Label>
        <asp:TextBox runat="server" ID="TxbBarcode"></asp:TextBox>
        <asp:Label runat="server" ID="LblAltura" Font-Bold="true"></asp:Label>
        <asp:TextBox runat="server" ID="TxbAltura"></asp:TextBox>
        <asp:LinkButton runat="server" ID="LBPrinter" href="print://1234/TxbBarcode/TxbAltura" OnClick="LBPrinter_Click"></asp:LinkButton>

How can i do that the information that is written in the textboxes gets inserted in the href?

Upvotes: 0

Views: 256

Answers (1)

Bharat
Bharat

Reputation: 1205

To handle client-side events, especially click we have an event handler onclientclick.

<asp:LinkButton runat="server" ID="LBPrinter" href="print://1234/TxbBarcode/TxbAltura" OnClick="LBPrinter_Click" onclientclick='changeLink(this)'></asp:LinkButton>    

Client-Side Javascript:

function changeLink(linkButton) {
  linkButton.href = "<new link>";
}

Upvotes: 1

Related Questions