Introduction
As you are reading this blog, you are accessing a website that means you are surfing the internet. In today's modern world, if a person is surfing on the internet, he knowingly or unknowingly uses many buttons in his everyday life.
Here we will discuss one of the buttons, which are LinkButtons. You will learn all about LinkButton, its properties, its methods, with examples.
LinkButton Syntax and Properties
Before moving on to LinkButton’s syntax and properties, let’s first learn about LinkButton.
As the name suggests, it is a button, but the factor that makes it different from the rest of them is its presentation style. It is a hyperlink-style button on the web page on the front end. It will look just like Hyperlink but has a function as a button.
Declarative Syntax and Class
Here, we see that ASP.NET provides a tag to create LinkButton. Here we will see the syntax of that:
<asp:LinkButton
AccessKey="string"
ID="string"
OnClick="Click event handler"
OnCommand="Command event handler"
OnClientClick="string"
OnDataBinding="DataBinding event handler"
OnDisposed="Disposed event handler"
OnInit="Init event handler"
OnPreRender="PreRender event handler"
OnLoad="Load event handler"
OnUnload="Unload event handler"
PostBackUrl="uri"
runat="server"
/>
Properties
These are some of the properties of the LinkButton in ASP.NET.
- Adapter: Gets the browser-specific adapter for the control.
- BackColor: Sets or gets the Web Server Control background color.
- ClientID: Gets the ASP.NET generated control ID for HTML markup language.
- Font: Gets all the font-related properties associated with Web Server Control.
- IsEnabled: Indicate with a value whether the control is enabled or not.
- Visible: Gets or sets whether a server control is rendered as UI on the page.
- Width: Sets the width of the Web Control Server.
Methods
Now, we will discuss some of the methods and their functions in ASP.NET.
- ApplyStyle(Style): Copies any nonblank element to the web control, overwriting the existing style elements of control.
- ClearCachedClientID(): Sets the cached ClientID value to null.
- DataBind(): Binds the data source to the server controls and its child controls.
- OnInit(EventErgs): Raises the Init event.
- OpenFile(String): Get a stream used to read a file.