lunes, 10 de diciembre de 2012

Redirecting LinkButton with blank tarjet



<asp:LinkButton ID="bPDF" runat="server" CausesValidation="False" CssClass="reset" Text="Ver Documento" OnClick="bPDF_Click" OnClientClick="aspnetForm.target ='_blank';"/>

protected void bPDF_Click(object senderEventArgs e)
{
    Response.Redirect("documento.pdf");
}

Validating values between TextBoxes using Javascript

<head runat="server">
    <title></title>
 
    <script type="text/javascript" language="javascript">
        function leave()
        {
            try
            {
                var val = document.getElementById('TextBox2').value;
                var compara = document.getElementById('TextBox1').value;
 
                if ((val > 0) && (compara > 0) && (compara > (val * 0.5)))
                {
                    document.getElementById('Label1').innerHTML = 'ERROR';
                    document.getElementById('Label2').innerHTML = 'ERROR';
                }
                else
                {
                    document.getElementById('Label1').innerHTML = '';
                    document.getElementById('Label2').innerHTML = '';
                }
            }
            catch (err)
            {
                //
            }
        }
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"  OnBlur="leave();" />
        <asp:Label ID="Label2" runat="server" Text="Label" />
        <br />
        <asp:TextBox ID="TextBox2" runat="server" OnBlur="leave();" />
        <asp:Label ID="Label1" runat="server" Text="Label" />
    </div>
    </form>
</body>
</html>

Setting value TextBox using Javascript

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
 
    <script type="text/javascript" lang="javascript">
        function setValue(TextBox)
        {
            TextBox.value = '0';
        }
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"  OnBlur="setValue(this);" />
    </div>
    </form>
</body>
</html>