?
Solved

refresh page in asp.net

Posted on 2009-04-15
19
Medium Priority
?
1,991 Views
Last Modified: 2012-05-06
i use radwinows to login page
i want when user login correctly
my master page auto refresh when radwindow is close
0
Comment
Question by:chandresh43
19 Comments
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24154765
you can call a javascript function

window.location.reload()

on the close event of radwindow on successful authentication
0
 
LVL 12

Expert Comment

by:wht1986
ID: 24154773
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);
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24154898
please give some example
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:OmerFarukZ
ID: 24154923
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24155064
not got please
give some c# example
0
 
LVL 14

Accepted Solution

by:
GiftsonDJohn earned 1500 total points
ID: 24155100

<%@ Register Assembly="RadWindow.Net2" Namespace="Telerik.WebControls" TagPrefix="radW" %>
<!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>Untitled Page</title>

    <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>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <radW:RadWindowManager ID="RadWindowManager1" runat="server">
            </radW:RadWindowManager>
            <input type=button onclick="OpenWindow()" value="Open Window" />
        </div>
    </form>
</body>
</html>

0
 
LVL 5

Author Comment

by:chandresh43
ID: 24155136
and where i put this code in master page or in rad window
0
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24155144
you have to put the code in the page where you use radwindow.
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24155517
<%@ 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
0
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24155588
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.
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24155702
<%@ 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
0
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24155743
How you are calling the function radopen to show the radwindow?
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24155833
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();
        }
   
0
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24155881
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);

        }
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24155899
ok i try it nothing happen
0
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24155946
are you getting any error? i mean javascript error anywhere
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24155966
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

0
 
LVL 5

Author Comment

by:chandresh43
ID: 24155968
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

0
 
LVL 5

Author Comment

by:chandresh43
ID: 24155978
i just want when user enter correct user name in adlogin.aspx
master page lable display that name
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question