Search code examples
htmlasp.netlabel

Combine Label.Text into ASP.Net Html Code


<asp:Label ID="Label4" runat="server" Text="+905554443322" Font-Size="Small"></asp:Label>

<a class="float" href="https://api.whatsapp.com/send?phone=" + "Label4.Text" target="_blank"> <i class="fa fa-whatsapp my-float"></i>

Dear members of the forum. In my ASP.Net work, I want to bring the text value of label4 to the place inside the link. I just couldn't make it.

So I want to bring the text value of Label4 to the relevant place in the web.whatsapp link. Any help will be appreciated. Thank you.


Solution

  • not quite clear, but since the lable is a server side control, then make the hyper link also server side.

    Eg this:

            <asp:Label ID="Label4" runat="server" Text="+905554443322" 
                Font-Size="Small"></asp:Label>
    
           <a class="float" id="MyRef" runat="server" href="" target="_blank"> 
               <i class="fa fa-whatsapp my-float"></i>
            </a>
    

    So, on page load, then set the href value:

    Private Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load
    
        MyRef.HRef = "https://api.whatsapp.com/send?phone=" + Label4.Text
    
    End Sub