Well, I bet this is a case for "This works on my machine".
The problem is:
I have a LinkButton
in my GridView
:
<asp:TemplateField HeaderText="Website">
<ItemTemplate>
<asp:LinkButton ID="L_Website" CausesValidation="true" runat="server" Text='<%# Eval("L_Website") %>'
CommandArgument="GoToWebsite" OnClientClick="return confirm('Are you sure you want to go to this Website?');"
CommandName="GoToWebsite"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
which I fill with data with a DataReader
:
dr["L_Website"] = Convert.ToString(reader["L_Website"]);
Maybe you also want to see the GoToWebsitecode:
protected void GV_Contacts_RowCommand(object sender, GridViewCommandEventArgs e)
{
string ID = string.Empty;
string status = string.Empty;
if (e.CommandName == "Edit")
{
//code here
}
else if (e.CommandName == "View")
{
//code here
}
else if (e.CommandName == "GoToWebsite")
{
LinkButton lb = (LinkButton)e.CommandSource;
GridViewRow gvr = (GridViewRow)lb.NamingContainer;
LinkButton LinkButton = gvr.Cells[8].Controls[1] as LinkButton;
if (LinkButton.Text.Substring(0, 3) == "www")
{
System.Diagnostics.Process.Start(LinkButton.Text);
}
else
{
System.Diagnostics.Process.Start("www." + LinkButton.Text);
}
}
}
It works fine on the local machine.
Its getting displayed, and if I click on it, the local version makes the confirmation, and then opens a new tab with this page.
On the server (IIS 6.0) it also gets displayed right, then if I click on it, it also makes the confirmation, but then it doesn't open a new tab with the page.
If I change the CausesValidation
, it also doesn't work.
If I have noOnClientClick
, it also doesn't work.
If I go (hover) over the LinkButton
, it shows me that it makes a postback.
Already thank you :)