Showing posts with label java scripts. Show all posts
Showing posts with label java scripts. Show all posts

Thursday, 23 January 2014

check postback in asp.net using javascript

read our previous articles how-to-disable-back-button-in-browser  and prevent-page-refresh-on-button-click-in-asp.net

  
<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Untitled Page</title>

    <script type="text/javascript">
var check = <%= Page.IsPostBack ? "1" : "0" %>;
if(check==1)
{
alert("PostBack window");
}
else
{
alert("first window");
}
</script>
</head>
<body>
    <form id="form1" runat="server"  >
    <div>
  This exaple to check posback in asp.net c#


        <asp:Button ID="Button1" runat="server" Text="Button" />

    </div>

    </form>

</body>

</html>

run code and view action ...

pass textbox value into a javascript function using asp.net c#

Read our previous articles  check-postback-in-asp.net and how-to-disable-back-button-in-browser
<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="Head1" runat="server">

    <title>Untitled Page</title>

<script type="text/javascript">
function function1()
{
var a=document.forms[0]["TextBox1"].value;
alert(a); 
}
</script>

</head>

<body>

    <form id="form1" runat="server">

    <div>

              <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

         

        <asp:Button ID="pass1" runat="server" OnClientClick="function1()"  Text="pass calue"

           />

    </div>

    </form>

</body>

</html>

check and view result ...

Friday, 6 December 2013

How to disable back button in browser

Add  onload="noBack();" onpageshow="if (event.persisted) noBack();" on body tag.
Example :

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body onload="noBack();" onpageshow="if (event.persisted) noBack();">
    <form id="form1" runat="server"  >
    <div>
    login name :  <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br />
    password :<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br />
        <asp:Button ID="Button1" runat="server" Text="ok" />
    </div>
    </form>
</body>
</html>