Click here to Skip to main content
15,888,008 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi this is my java script function
HTML
<script type="text/javascript">
  
  function here()  
  {
     return(confirm("YOU WANT"));  
  }
  
  </script>


this is my text box ...
ASP.NET
<asp:TextBox ID="TextBox1" Onchange="return here()" runat="server"
       AutoPostBack="True" ontextchanged="TextBox1_TextChanged"></asp:TextBox>


and this is my cs code
C#
protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        Response.Write("i will peroform data base task");

    }



now my problem is ... my javascript function returning true then also my .cs page function is not calling....
Posted
Updated 6-Jan-12 1:24am
v2

Dear Dilip,

It does not allow you to call Javascript event and server side event at a time, this can be achieved by calling server side function from client side event.
use jquery.post() to call a server side function
http://api.jquery.com/jQuery.post/[^]
or
use pagemethods
http://www.dotnetcurry.com/ShowArticle.aspx?ID=109[^]

or call java script function from server side event.
how to call javascript function .cs file[^]

This will helpful to you.

Thanks
 
Share this answer
 
v4
Change your textbox event Onchange with Onblur like,

XML
<asp:TextBox ID="TextBox1" Onblur="return here()" runat="server"
AutoPostBack="True" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
 
Share this answer
 
Comments
dilip.aim11 6-Jan-12 7:49am    
i already try this .. in that case it will call server side function even when we will click on no
Sridhar Patnayak 6-Jan-12 7:50am    
Onblur event does not allow you to call client side and server side events at a time. He want to execute both events at a time.
JavaScript
function here()
{
   var result = confirm("YOU WANT");
   if(result)
   {
      __doPostBack('UNIQUE NAME OF TEXT BOX', null);
   }
   else
   {
          return false;
   }
}




ASP.NET
<asp:TextBox ID="TextBox1" Onchange="return here()" runat="server"
       AutoPostBack="True" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900