Reputation: 117
I have this LinkButton:
<asp:LinkButton ID="lbiOpen" runat="server" />
and my Code behind:
protected void Page_Load(object sender, EventArgs e)
{
lbiOpen.Attributes.Add("onclick", "javascript:window.location.href('New.aspx');");
}
If a user clicks on the LinkButton a popup should open. But it doesn't work. When I click on nothing happens.
When I Change window.location.href = window.open
it works, but it opens in another tab.
Upvotes: 2
Views: 9783
Reputation: 11
<asp:LinkButton ID="lbiOpen" OnClientClick="window.open('New.aspx', '_self');return false;" Text="Submit" runat="server" />
Upvotes: 1
Reputation: 5203
This works for me:
<asp:LinkButton ID="lbiOpen" runat="server">Example</asp:LinkButton>
protected void Page_Load(object sender, EventArgs e)
{
lbiOpen.Attributes.Add("onclick", "window.open('New.aspx', 'New Window', 'width=200,height=100')");
}
Upvotes: 1
Reputation: 857
window.open("New.aspx", "_self"); // will open in the same windows
window.location.href = "New.aspx"; // will open in a new window
Upvotes: 2