<asp:LinkButton ID="lnkbtnMoreTagRules" runat="server"
CommandName='<%#Eval("Value")%>'
CommandArgument='<%# string.Format("{0}||||{1}", Eval("Tag"),
Eval("TagAppearance"))%>'
OnCommand="lnkbtnMoreTagRules_Command">Več pravil</asp:LinkButton>
I want to close current window tab and open new one.
How can i open a new window tab with linkbutton. target="_blank" not helping.
As link button is posted back, so it cannot be used for a GET request. instead use HyperLink Class
LinkButton works like a Button and does not have a Target attribute. Use a HyperLink instead and set the Target.
You need something like this
<asp:LinkButton id="LinkButton1" runat="server" onClientClick="window.open('http://asp.net');"
I doubt we have any foolprrof code to open link in tabs because most of the browser activities are totally under the control of users.
User can change thier browser settings in the way they wanted to behave.
There is nice discussion related to this in below thread, it will be interesting for you,
http://www.dynamicdrive.com/forums/archive/index.php/t-19843.html
Related
So I have this line of code which uses a hyperlink
<asp:HyperLink style="text-decoration:none" runat="server" Text="View Order" NavigateUrl='<%# "OrderDetails2.aspx?oID=" + Eval("oID") %>'>/asp:HyperLink>
Works perfectly fine but when I try to use a button to do the same thing (since I have to use an OnClick method), it doesn't allow me to use NavigateUrl and Eval in it. Any alternative methods?
Thats because asp:button does not have a property called NavigateUrl, its only a valid property for an hyperlink.
You can use JavaScript click event for an asp:hyperlink.
Not sure what you're trying to do.
If you are trying to add a link to another page, just use asp:hyperlink but use CSS to make it look like a button.
If you really do want a button with a server-side click event, you can add the following to the end of the click event handler:
Response.Redirect(String.Format("OrderDetails2.aspx?oID={0}", oID));
I am trying to right click on a LinkButton and open it in a new tab or seperate window page displays nothing. I found some solution for the use of Hyperlink button as it has property to set target to "_blank" but LinkButton has not any target attribue.
I want to use LinkButton instead of hyperlink button, its just because i can't set command arguement or command name on hyperlink button and can't fire an event on it.
<asp:LinkButton ID="lnkHeadingHindi" Text='<%#Patrika.Common.ConvertNews(Eval("strMainHeadingHin").ToString())%>' CommandArgument='<%#Eval("intNewsId") %>' runat="server"></asp:LinkButton>
It would be great if anybody has a solution and let me know in case of any concern.
Thanks !!
Based on the accepted answer to this question, if you want to perform a POST (such as a LinkButton does) but have the result open in a new window, you need to add target="_blank" to the form on the page, not the link itself.
Obviously you don't want to do this when you initially render the page, as everything that caused a postback would open in a new window.
Instead, try adding the following attribute to your LinkButton:
OnClientClick="$('form').attr('target', 'blank')"
This will dynamically set the form attribute just before the form is posted back by a click to the link.
Note that this doesn't give the right-click functionality you want, but it does work to open in a new window on a left-click.
If you don't have access to JQuery, you'll need to do something like
protected void Page_PreRender(object se, EventArgs e)
{
this.Page.Form.ID = "someUniqueID"; // unless your form already has an ID
yourLinkButton.OnClientClick =
"document.getElementById('" +
this.Page.Form.ClientID +
"').setAttribute('target', '_blank')";
}
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:
1) Use a HyperLink control, and set the Target property
2) Provide a method to the OnClientClick property
that opens a new window to the correct place.
3) In your code that handles the PostBack add some JavaScript to fire on PageLoad that will open a new window correct place.
If you like when click the link button,then open new window,
please see this
insert base tag like this
<head>
<base target="_blank" />
</head>
If you want to pass some information to the page using hyperlink, pass it in the url using QueryString.
<asp:HyperLink id="hyperlink1"
NavigateUrl="~/MyPage.aspx?intNewsId=10"
Text="ClickMe"
Target="_blank"
runat="server"/>
You can't have it both ways, you'll have to choose between:
1) the linkbutton executing some code in the current page
2) a hyperlink opening another page in a new window
I guess you want to have the linkbutton executing some code in the new page, but that's impossible.
or if u like use . anger tag
Just render an anchor with href set to appropriate url and set the target attribute to _blank it will open the url into new window
<a href="urlOfThePage" target="_blank" >Click me</a>
I have a number of buttons on my page and I would like to have some kind of notes appearing next to it explaining what the button is for when they hover over any particular button.
How would I go about achieving that?
(I am after something similar to when you hover over the tags below on this stackoverflow page...)
You should do like this
<form runat="server">
<asp:Button id="button1" Text="Submit" runat="server"
ToolTip="This is an example-button"/>
</form>
Here tooltip shows your message.
Tap into the hover of that item using jQuery: http://api.jquery.com/hover/
Attach a function to hover that shows and hides a div. There are many examples of showing popup windows using jQuery. A quick Google search took me Here. You will also have to position the popup in the correct location. You can get the correct location using jQuery as well. http://api.jquery.com/position/
If you prefer using codeBehind, try this:
nameOfControlButton.ToolTip = "Here is my tooltip comment";
I am using a window.open() in a hyperlink to open a popup in my page. I have a folder structure like
parent
Controls
Reports
reportviewer.aspx
Search.aspx
form search.aspx i need to open reportviewer.aspx in a popup(javascript) .How to achive this ?How to pass the url ?
In current situation the path could be
window.open("reportviewer.aspx")
but i think better way is to use ResolveUrl or ResolveClientUrl
Try something like that:
<asp:HyperLink runat="server" OnClientClick='<%# string.Format("window.open(\"{0}\");
return false;", ResolveUrl("~/AppFolder/YourPath/reportviewer.aspx"))%>' NavigateUrl="#" %>
Try this:
Button1.Attributes.Add("onclick", "javascript:window.open('/reportviewer.aspx');");
Since both reportviewer.aspx and search.aspx are in the same folder,
the url can be passed as under
window.open('reportviewer.aspx');
Take care of opening windows in pop-ups because some navigators are bloking popups. It causes me some explications about navigator's security to users.
I'm now using NyroMal it's a jquery plugin to make popups "in the page". No blocking..
there's some tutorials in the project's web site to learn how it is working..
I'm pretty new to this, infact this is my first post.
I'm using Visual Studio 2005. On my .aspx page, I have a 'loginStatus' control so the user can logout of a page which works well. However the 'loginStatus' control is not a button, it's text ("logout"). Is it possible to make this into a button?
Here is the line of code:
<asp:LoginStatus ID="LoginStatus1" runat="server" OnLoggingOut="LoginStatus1_LoggingOut" />
Would I just add some style somehow? If so, please help me.
Thanks.
Haven't tested this, but it might solve your problem : forum post
Otherwise you might use jQuery to solve this. (I think...)
You can try this:
<asp:LoginStatus ID="HeadLoginStatus" runat="server"
LogoutAction="Redirect"
LogoutText="<input type='button' value='Log Out' />"
LogoutPageUrl="~/"/>
The LogoutText attribute contains the definition of a simple button, that you can customize with css and js.
Just use LoginImageUrl or LogoutImageUrl
<asp:LoginStatus runat="server"
LogoutImageUrl="~/App_Themes/Theme1/Images/logout.png"
LoginImageUrl="~/App_Themes/Theme1/Images/login.png" />
Using JavaScript:
Grab the url of the link and add a button which, when onclick'ed, points the browser to that url. Then add display:none to the original link with CSS.
You can also use an image as Colin says, but that would fake a button and I assume you want a real button.
YOu could try to render it using an Image, as stated here
The LoginStatus control displays either a text or an image link, depending on the setting of the LoginImageUrl and LogoutImageUrl properties. You can display either text or images for one or both states.
Cheers, I will have a look into this :)
I think it's strange that the option of turning it into a button is not already available.
You could wrap the LoginStatus inside of a LinkButton (Or any kind of button).
<asp:LinkButton id="LinkButton1" runat="server">
<asp:LoginStatus id="LoginStatus1" runat="server" />
</asp:LinkButton>
then use the LinkButton1 events.
You could always just extend the LoginStatus control by creating a derived class, and overriding the rendering behaviour to change the output elements into your desired elements, or add style attributes, or whatever.
(apologies for VB)
Public Class MyLoginStatus
Inherits System.Web.UI.WebControls.LoginStatus
Public Overrides Sub RenderBeginTag(ByVal writer As System.Web.UI.HtmlTextWriter)
writer.AddStyleAttribute("display", "none")
MyBase.RenderBeginTag(writer)
End Sub
End Class
This kind of behaviour could be extended to turn the output into a button, if you so wish, either in aggregate (modifying the final rendered output by creating your own HtmlTextWriter enclosing a StringWriter and invoking the base methods), or by injecting your own behaviour into the relevant render events.
Have you looked into Control Adapters - this allows you to alter the HTML generated. It's primarily used for adapting HTML for different browsers and devices, but can be used to have complete control over server controls.
Lee
I know this is an old post but I'll chime in.
Here's a very simple way to make a button out of the LoginStatus control. Set the control CssClass to a bootstrap button and your good to go. Whatever text you have for the login and logout will go into the button.
<asp:LoginStatus ID="LoginStatus1" runat="server" CssClass="btn btn-primary" LogoutPageUrl="yourlogin.aspx" />
http://www.w3schools.com/bootstrap/bootstrap_buttons.asp