Link button in asp.net?
I developed a web appl开发者_高级运维ication, in that main page i used link buttons and write some code in link button click event, Problem is when i right click on the link buttons i am not finding open in new tab option in link buttons, how can i solve this problem can u help me please.
The LinkButton control acts like a button.
Use HyperLink control instead if you want to have the href behavior.
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>
HyperLink1.Text = "Go to StackOverflow";
HyperLink1.NavigateUrl = "http://www.stackoverflow.com";
I think what @jarrett meant in his comment is that the resulting html that a LinkButton control generates is a javascript:
href, not an href to a url - it's something along the lines of javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$ContentPlaceHolder1$loginBtn", "", true, "", "", false, true))
If you want the html output of a standard anchor tag/HyperLink (and the corresponding client browser behavior, including right-click to open in new tab or window) then use a standard anchor tag in your page <a href="pageurlhere.com">Link to your page</a>
If you need to be able to access the anchor tag from code-behind (assuming a Web Forms application) then you can add runat="server"
to the tag and make it into a server-side Html Control, which is accessible to your code-behind.
精彩评论