0

LinkButton click by JavaScript not work with google chrome.

<asp:LinkButton runat="server" ID="lnkSearch" OnClick="lnkSearch_Click" Text="abc" />
<input id="Button2" type="button" value="Click Link" onclick="abc();" />

<script language="javascript" type="text/javascript">
 function abc() {
      document.getElementById('<%= lnkSearch.ClientID %>').click();
 }
</script>

Any one has idea?

JD Varu
  • 216
  • 1
  • 2
  • 9

3 Answers3

0

For asp linkbutton a client click should be:

OnClientClick="abc(); return false"
freedeveloper
  • 3,670
  • 34
  • 39
0

try after adding following code to OnPreInit method of base page.

protected override void OnPreInit(EventArgs e)
{
    if (Request.UserAgent != null && (Request.UserAgent.IndexOf("AppleWebKit") > 0))  // added for compatibility issues with chrome 
    {
        this.ClientTarget = "uplevel";
    }

    base.OnPreInit(e);
}

refer original post asp.NET LinkButton not working in Google Chrome

Community
  • 1
  • 1
Hemant Metalia
  • 29,730
  • 18
  • 72
  • 91
0

i got my answer as follow

function Search() { window.location.href = document.getElementById('<%= lnkSearch.ClientID %>'); return false; }

JD Varu
  • 216
  • 1
  • 2
  • 9