Sandeep Singh Shekhawat

Sandeep Singh Shekhawat

  • NA
  • 19.9k
  • 30.7m

Why page is refreshing on onclientClick of asp button?

Sep 30 2012 8:51 AM
I have a .aspx page and it has one text box and button Like:

Enter Movie Id :<asp:TextBox ID="txtMovieId" runat="server"></asp:TextBox>
    <asp:Button ID="btnSubmit" runat="server" Text="Movie Detail" OnClientClick="OnGetMovieDetailByMovieId()"  />

OnClientClick i am calling a javacript function 

function OnGetMovieDetailByMovieId()
        {
            var movieId = document.getElementById('<%= txtMovieId.ClientID %>').value;
            MovieService.GetMovieDetailByMovieId(movieId, OnGetMovieDetailByMovieIdComplete, OnError)
        }

and this function is calling Ajax-enable WCF service method from MovieService.

I have also defiend both callback function but when i click on button its get data from wcf web service and page again refresh and I lost data on page.

So why page is refreshing while i have only onclientclick of button.
Please suggest.

Thanks
Sandeep





Answers (7)