In my application I have some link buttons there but when I right click on them I cannot (they are in disable mode) find the menu items
Open in new tab or
Open in new window.
How do I show those menu items?
<asp:LinkButton id="lbnkVidTtile1" runat="Server" CssClass="bodytext" Text='<%#Eval("newvideotitle") %>' />
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
From the docs:
Use the LinkButton control to create a hyperlink-style button on the Web page. The LinkButton control has the same appearance as a HyperLink control, but has the same functionality as a Button control. If you want to link to another Web page when the control is clicked, consider using the HyperLink control.
As this isn’t actually performing a link in the standard sense, there’s no
Target property on the control (the
HyperLink control does have a
Target) – it’s attempting to perform a PostBack to the server from a text link.
Depending on what you are trying to do you could either:
- Use a
HyperLinkcontrol, and set the
- Provide a method to the
OnClientClickproperty that opens a new window to the correct place.
Here is your Tag.
<asp:LinkButton ID="LinkButton1" runat="server">Open Test Page</asp:LinkButton>
Here is your code on the code behind.
Hope this will be helpful for someone.
To do the same with a link button inside a template field, use the following code.
Use GridView_RowDataBound event to find Link button.
Dim LB as LinkButton = e.Row.FindControl("LinkButton1") LB.Attributes.Add("href","../Test.aspx") LB.Attributes.Add("target","_blank")
try by Adding following onClientClick event.
<asp:LinkButton id="lbnkVidTtile1" OnClientClick="aspnetForm.target ='_blank';" runat="Server" CssClass="bodytext" Text='<%# Eval("newvideotitle") %>' />
This is not perfect, but it works.
- LinkButton executes HTTP POST operation, you cant change post target here.
- Not all the browsers support posting form to a new target window.
- In order to have it post, you have to change target of your “FORM”.
Try to find out ID of your form element in generated aspx, and you can change target like…
getElementByID('theForm').target = '_blank' or 'myNewWindow'
When the LinkButton Enabled property is false it just renders a standard hyperlink. When you right click any disabled hyperlink you don’t get the option to open in anything.
lbnkVidTtile1.Enabled = true;
that you use a standard HyperLink control.
It throws error.
Microsoft JScript runtime error: ‘aspnetForm’ is undefined
<asp:LinkButton ID="LinkButton1" runat="server" target="_blank">LinkButton</asp:LinkButton>
Use target=”_blank” because It creates anchor markup. the following HTML is generated for above code