Sunday, 7 June 2015

jquery settimeout

setTimeout(function () {

window.location.href="form location";},2000);

or
in default.aspx design

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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></title>
    <style type="text/css">
        body
        {
            font-family: Arial;
            font-size: 10pt;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    Enter Name:
    <asp:TextBox ID="txtName" runat="server" />
    <br />
    <asp:Button Text="Submit" runat="server" OnClick="Submit" /><br />
    <br />
    <asp:Label ID="lblMessage" ForeColor="Green" Font-Bold="true" Text="Form has been submitted successfully."
        runat="server" Visible="false" />
    <script type="text/javascript">
       
        window.onload = function () {
            debugger;
            var seconds = 5;
            setTimeout(function () {
                document.getElementById("<%=lblMessage.ClientID %>").style.display = "none";
            }, seconds * 1000);
        };
    </script>
    </form>
</body>
</html>

in code behind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Submit(object sender, EventArgs e)
    {
        lblMessage.Visible = true;
    }
}

Jquery popup

1. put <script src="AppResource/JS/jquery-1.9.1.min.js" type="text/javascript"></script>  and
<script src="AppResource/JS/jquery-ui.js" type="text/javascript"></script>  into master page or corresponding page.

2. Inside aspx page write below codes

<script type="text/javascript">

function Confirmpopup(){
$('#hider').fadeIn("slow");
$("#divConfirm").dialog({modal:true})
}

function CloseModalWnd(){
$('#hider').fadeOut("slow");
$(".ui-dialog-content").dialog().dialog("close");

function HideModalWind() {
$("#hider").hide();
$("#divConfirm").hide();
}

<style type="text/css">

.ui-dialog-content ui-widget-content{
width: 800px !import;
height:500px !import;
}

#divConfirm{
background-color:white;
width:1000px !import;
margin-top: -40px;
height:500px !impotant;
margin-left:-200px;
}
</style>

3. In code behind

declare globaly

 bool isHideModel=true;

write
protected override void onInit(EventArgs e)
{
if(isHideModel)
ScriptManager.RegisterStartupScript(Page, typeof(Page),"Hidepopout","HideModalWind();",true);
}

in button click to display popup code

protected void popout_click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript('Page,typeof(Page),"popout","Confirmpopup();",true);
}

4. ok close button inside popup

<input type="button" id="btnOk" value="Ok" onClick=""/>
<input type="button" id="btnClose" value="Close" style="Width: 50px; font-weight:bold;" onClick="CloseModalWnd();" />