BOBIN JOSEPH
BOBIN JOSEPH

Reputation: 1022

Why does java script click() function for asp Button is not working in chrome browser?

I am using java script click event to call one server function to assign some session values. But this java script is only calling in the Onclick event of the Anchor tag. this redirecting to other pages.

<a  onclick="javascript:SetSession();" href="Some other page">

<asp:Button runat="server" ID="ButtonId" Style="display: none;" OnClick="SetSession" />

Then the Javascript function is

        function SetSession()
        {   
            var y = some values;    
            $("#hiddenfield").val(y);   

            document.getElementById("ButtonId").click();            
        }

Then the C# code is like

  protected void SetSession(object sender, EventArgs e)
    {
        Session["SessionName"] = this.HiddenField.Value;
    }

Its working fine in all browsers except Chrome. Even it is not calling the Button.Click() Server function In chrome ! I need the same functions. AnyOne Know the solution for chrome ?

Upvotes: 0

Views: 1371

Answers (1)

GraDea
GraDea

Reputation: 588

Try add return false; in javascript-function.

Upvotes: 2

Related Questions