Link to home
Start Free TrialLog in
Avatar of chandresh43
chandresh43Flag for India

asked on

refresh page in asp.net

i use radwinows to login page
i want when user login correctly
my master page auto refresh when radwindow is close
Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

you can call a javascript function

window.location.reload()

on the close event of radwindow on successful authentication
with radwindow you can run a javascript callback function on the close event of the window. think it is called ClientCallBackFunction

in that JS callback function you can call:

window.location.reload(); or
window.location.href=window.location.href; or
history.go(0);
Avatar of chandresh43

ASKER

please give some example
not got please
give some c# example
ASKER CERTIFIED SOLUTION
Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
and where i put this code in master page or in rad window
you have to put the code in the page where you use radwindow.
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="administratormaster.master.cs" Inherits="administrator_administratormaster" %>

<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<!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">
<script>
         function OpenWindow()
        {
              radopen("http://www.google.com","RadWindow2");
              ConfirmClose("RadWindow2");
        }
       
        function ConfirmClose(WinName)
        {
              var oManager = GetRadWindowManager();
              var oWnd = oManager.GetWindowByName(WinName);
              var CloseButton = document.getElementById("CloseButton" + oWnd.Id);
              CloseButton.onclick = function()
                  {
                      CurrentWinName = oWnd.Id;
                     window.location.reload();
                  }
        }
       
        function confirmCallBackFn(arg)
        {
            if (arg == true)
                {
                    var oManager = GetRadWindowManager();
                      var oWnd = oManager.GetWindowByName(CurrentWinName);
                      oWnd.Close();
                }
        }                    
    </script>
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        .style1
        {
            width: 157px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style="width: 932px">
        <telerik:RadWindow ID="RadWindow1" runat="server">
        </telerik:RadWindow>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:Label ID="lbluser" runat="server"
            style="z-index: 1; left: 710px; top: 25px; position: absolute; height: 16px"
            Text="Label"></asp:Label>
        <br />
        <br />
        <telerik:RadMenu ID="RadMenu1" Runat="server">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
            <Items>
                <telerik:RadMenuItem runat="server" Text="Master">
                </telerik:RadMenuItem>
            </Items>
        </telerik:RadMenu>
    </div>
    <table style="width:100%;">
        <tr>
            <td class="style1">
                <telerik:RadTreeView ID="RadTreeView1" Runat="server"
                   
                    style="z-index: 1; left: 13px; top: 154px; position: absolute; height: 87px; width: 139px">
                    <Nodes>
                        <telerik:RadTreeNode runat="server" Text="Add Items"
                            NavigateUrl="~/administrator/addtems.aspx">
                        </telerik:RadTreeNode>
                    </Nodes>
<CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation>

<ExpandAnimation Duration="100"></ExpandAnimation>
                </telerik:RadTreeView>
            </td>
            <td>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
       
            <p>
                <br />
            </p>
            <p>
            </p>
            <p>
            </p>
            <p>
            </p>
       
        </asp:ContentPlaceHolder>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>



but not work
Hi,

What I gave is just an example.

 in the function OpenWindow() the radwindow is opened and the close event is registered by ConfirmClose("RadWindow2"). You have to call the ConfirmClose function from where you call the radopen function by ConfirmClose("RadWindow1"). I am using RadWindow1 because your code has radwindow with id RadWindow1

the only function you need to add is

function ConfirmClose(WinName)
        {
              var oManager = GetRadWindowManager();
              var oWnd = oManager.GetWindowByName(WinName);
              var CloseButton = document.getElementById("CloseButton" + oWnd.Id);
              CloseButton.onclick = function()
                  {
                      CurrentWinName = oWnd.Id;
                     window.location.reload();
                  }
        }

and you have to call the above function when you open the radwindow.
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="administratormaster.master.cs" Inherits="administrator_administratormaster" %>

<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<!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">
<script>
       
       
        function ConfirmClose(WinName)
        {
              var oManager = GetRadWindowManager();
              var oWnd = oManager.GetWindowByName(WinName);
              var CloseButton = document.getElementById("CloseButton" + oWnd.Id);
              CloseButton.onclick = function()
                  {
                      CurrentWinName = oWnd.Id;
                     window.location.reload();
                  }
        }
       
       
                           
    </script>
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        .style1
        {
            width: 157px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style="width: 932px">
        <telerik:RadWindow ID="RadWindow1" runat="server">
        </telerik:RadWindow>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:Label ID="lbluser" runat="server"
            style="z-index: 1; left: 710px; top: 25px; position: absolute; height: 16px"
            Text="Label"></asp:Label>
        <br />
        <br />
        <telerik:RadMenu ID="RadMenu1" Runat="server">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
            <Items>
                <telerik:RadMenuItem runat="server" Text="Master">
                </telerik:RadMenuItem>
            </Items>
        </telerik:RadMenu>
    </div>
    <table style="width:100%;">
        <tr>
            <td class="style1">
                <telerik:RadTreeView ID="RadTreeView1" Runat="server"
                   
                    style="z-index: 1; left: 13px; top: 154px; position: absolute; height: 87px; width: 139px">
                    <Nodes>
                        <telerik:RadTreeNode runat="server" Text="Add Items"
                            NavigateUrl="~/administrator/addtems.aspx">
                        </telerik:RadTreeNode>
                    </Nodes>
<CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation>

<ExpandAnimation Duration="100"></ExpandAnimation>
                </telerik:RadTreeView>
            </td>
            <td>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
       
            <p>
                <br />
            </p>
            <p>
            </p>
            <p>
            </p>
            <p>
            </p>
       
        </asp:ContentPlaceHolder>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
ok thats but where i call this function
How you are calling the function radopen to show the radwindow?
protected void Page_Load(object sender, EventArgs e)
    {
        Session.Timeout = 1;


        if (Session["aduserlogin"] == null)
        {

            RadWindow1.NavigateUrl = "adlogin.aspx";
            RadWindow1.VisibleOnPageLoad = true;
            RadWindow1.VisibleStatusbar = false;
            RadWindow1.VisibleTitlebar = false;



        }
        else
        {
            lbluser.Text = Session["aduserlogin"].ToString();
        }
   
okay, you are doing from code behind.  try this.

if (Session["aduserlogin"] == null)
        {

            RadWindow1.NavigateUrl = "adlogin.aspx";
            RadWindow1.VisibleOnPageLoad = true;
            RadWindow1.VisibleStatusbar = false;
            RadWindow1.VisibleTitlebar = false;

           Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "radclosehandler", "setTimeout('ConfirmClose(\"RadWindow1\")',500)", true);

        }
ok i try it nothing happen
are you getting any error? i mean javascript error anywhere
no i give not get any error

 if (Session["aduserlogin"] == null)
        {
 
            RadWindow1.NavigateUrl = "adlogin.aspx";
            RadWindow1.VisibleOnPageLoad = true;
            RadWindow1.VisibleStatusbar = false;
            RadWindow1.VisibleTitlebar = false;
           
 
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "radclosehandler", "setTimeout('ConfirmClose(\"RadWindow1\")',500)", true);
 
 
           
        }
 
        
        else
        {
            lbluser.Text = Session["aduserlogin"].ToString();
        }
    

Open in new window

this adlogin.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ADLOGIN.aspx.cs" Inherits="administrator_ADLOGIN" %>
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<!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>
</head>
<body onunload="CloseAndRefresh()" >
    <form id="form1" runat="server">
    	<script type="text/javascript">
			//This code is used to provide a reference to the radwindow "wrapper"
    	    function GetRadWindow() {
    	        var oWindow = null;
    	        if (window.radWindow) oWindow = window.radWindow;
    	        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    	        return oWindow;
    	    }
 
 
    	    function ButtonJS_Click() {
    	        if (document.getElementById('<%=Txtusername.ClientID%>').value == 'ajay') {
    	            Cancel_Clicked();
    	        }
    	    }
 
    	    function CloseAndRefresh() {
    	        window.opener.location.href = window.opener.location.href;
    	        window.close();
    	    }
			function Cancel_Clicked()
			{
				var oWindow = GetRadWindow();			
				oWindow.close();
			}				
		</script>	
    
    <div>
    
    </div>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
        <telerik:RadTextBox ID="Txtusername" Runat="server">
        </telerik:RadTextBox>
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
    </form>
</body>
</html>

Open in new window

i just want when user enter correct user name in adlogin.aspx
master page lable display that name