locked
postback javascript, why is post occuring? RRS feed

  • Question

  • User1893941629 posted

    my friend go stuck in this problem, but found the answer

    so i thought it may help others also,,


    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="I1.aspx.cs" Inherits="t2.I1" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Post Back</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        
        
        
        
        <div>
        <p>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        Textbox one   
        </p>
        <p>
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        Textbox two
        </p>
        </div>
            <asp:Button ID="Button1" runat="server" Text="Shift"
            OnMouseOver="text(); return false;"
            />
        </div>



    <div>
    <p>post back occurs, as i return something to server</p>
         <asp:Button ID="Button2" runat="server" Text="Click Me | Postback"  OnClientClick="text()" />
    </div>


    <div>
    <p>post back does not occurs, as my return is false</p>
     
         <asp:Button ID="Button3" runat="server" Text="Click Me | No Post back"  
         OnClientClick="text(); return false;" />
    </div>   
     
     
        </form>
    </body>
    </html>


    <script type="text/javascript" language="javascript">
         
       function text()
    {

    document.getElementById('TextBox2').value = document.getElementById('TextBox1').value;


     
     }
     
     
    </script>

    Wednesday, June 23, 2010 6:24 AM

All replies