I have 2 pages (Home and Сategory)
Load page Home on there's button. Click button run panel RadWindow (NavigateUrl: Сategory).
protected void ShowWindow()
{
string script = "function f(){$find(\"" + RadWindow_editor.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
}
protected void RadButtonEdit_Click(object sender, EventArgs e)
{
ShowWindow();
}
Load RadWindow NavigateUrl - Сategory on there's button. Click button close RadWindow.
protected void RadButtonEdit_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "Close();", true);
}
function GetRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return oWindow;
}
function Close() {
var oWindow = GetRadWindow();
oWindow.argument = null;
oWindow.close();
return false;
}
How to refresh the page Home? (Click button close RadWindow)
Thank you!
Here's how: http://www.telerik.com/community/forums/aspnet-ajax/window/how-to-refresh-the-page-click-button-close-radwindow.aspx#2894238.
If your page does not refresh, then the problem is in the page. Having a has in the URL can cause this problem. Make sure you change the URL so you have a fresh GET request.
There are client-side events like OnClientBeforeClose and OnClientClose.
http://demos.telerik.com/aspnet-ajax/window/examples/clientsideevents/defaultcs.aspx
and check this link, it gives you an idea.
How to close the radwindow on serverside and refresh the parent page
You should also look at using a RadAjaxManager in the parent page to send the window events to the parent as shown in the the following demo: Grid and Window. It focuses on refreshing a grid, not a page in your instance, but the concept of sending events to the parent page remains the same.
Related
private void AddOrderItems(object sender, EventArgs e)
{
string url = "Orderdetails.aspx";
ClientScript.RegisterStartupScript(this.GetType(), "OpenWin", "<script>openNewWin('" + url + "')</script>");
}
I am using above code to open a popup window.
I have a page order.aspx from which I am opening another aspx page (Orderdetails.aspx).
Orderdetails.aspx page opens as a popup.
once user close the window(Orderdetails.aspx) , Orders.aspx page should post back and load newly added items.
How to catch the close event of the popup window?
Put this script block in your child window:(Orderdetails.aspx)
<script>
window.onunload = refreshParent;
function refreshParent() {
window.opener.location.reload();
}
</script>
I am developing an application by using ASP.Net WebForm. Once user click a button, application will navigate to a new page and prompt out a dialog box "Welcome to JackiesGame"
However, I able to navigate to new page but the alert dialog box does not display.
The following is my sample code
void cmdCancel_Click(object sender, EventArgs e)
{
HttpContext.Current.Response.Redirect(Globals.NavigateURL(TabId), true);
Page page2 = HttpContext.Current.CurrentHandler as Page;
ScriptManager.RegisterStartupScript(page2, page2.GetType(), "alertMessage", "alert('Insert Successfully')", true);
}
Add the following in page 2. On the page load it will register only for the first time the page loads the script.
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
var reg = Request["Welcome"]
if(reg != null && reg.ToString() == "yes"){
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", "alert('Insert Successfully')", true);
}
}
}
All code after the redirect is getting ignored since it has to redirect to a new page. So the code never gets triggered.
EDIT
Added a example of how it can look further
void cmdCancel_Click(object sender, EventArgs e)
{
string myUrl = Globals.NavigateURL(TabId)+"?Welcome=yes";
HttpContext.Current.Response.Redirect(myUrl, true);
}
In codebehind of my asp.net page has a button and when single-click her open a RadWindow, don't have a problem.
The problem is when somebody close the radwindows, because to open is necessary double-click. I don't like this.
For me control refresh to disable the double-click page I use:
Boolean IsPageRefresh;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["postids"] = System.Guid.NewGuid().ToString();
Session["postid"] = ViewState["postids"].ToString();
}
else
{
if (ViewState["postids"].ToString() != Session["postid"].ToString())
{
IsPageRefresh = true;
}
Session["postid"] = System.Guid.NewGuid().ToString();
ViewState["postids"] = Session["postid"].ToString();
}
}
But don't work, somebody use F5 or click in button the radwindow open again.
How can I detect to difference when use F5 and Click button?
With the click event of a link button calling a server side method from Form1
Form1 aspx.cs page code:-
protected void lnkTakeAction_OnCommand(object sender, CommandEventArgs e)
{
if (e.CommandName == "duplicate")
{
//Some operations conditional
//If condition true
//call javascript method to call a javascript function to open a rad window
ScriptManager.RegisterStartupScript(this, typeof(System.Web.UI.Page), "ABC "ABCPopUp" + ID + "','Tag');", true);
}
}
Form1 aspx javascript code:-
function ABCPopUp(ID, Tag) {
var oWindow = window.radopen('XYZPage.aspx?ID=' + scoreMethodId + '&Tag=' + mode, 'rdWindowMapping');
oWindow.SetSize(600, 500);
oWindow.Center();
var titleBar = oWindow.GetTitlebar();
$telerik.$(titleBar).parent().hide();
return false;
}
Issue facing - The XYZPage is not opening.The same functionality works if I call the function ABCPopUp from javascript.But when I call from server side the form is not opening.Please give expert advice
Most likely, the script runs too early. You have two options:
use AJAX for the grid and do not include the RadWindow in the response
OR, use the Sys.Application.Load event to call your function: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-opening-from-server.html.
I have a main page with a Gridview that shows data from a Database. In the gridview there is a button, when this button is clicked a Dialog will appear allowing u to edit the selected row. The dialog is created as an aspx class. When i edit the data and close down the dialog i want to refresh my GridView on the Main page so the edited data is represented. How can i do this?
my code for editing the data and closing down the dialog is this:
protected void editButton_Click(object sender, EventArgs e)
{
string alias = Request.QueryString["alias"];
string custid = Request.QueryString["custid"];
controller.EditDeliveries(custid, alias, tdaysField.Text, thoursField.Text, ttypeField.Text, pdaysField.Text, phoursField.Text, ptypeField.Text);
ClientScript.RegisterClientScriptBlock(GetType(), "onUpload", "<script type='text/javascript'> window.close();</script>");
}
Can anyone help ?
And if u need to see more code please tell me.
Just set your datasource again and rebind it in the postback
gvMyGrid.DataSource = myData; //Fresh from the database
gvMyGrid.DataBind(); //Bam, fresh data
Edit: Oh and if it's another Control that is the source of the postback, you can use a Bubble Event to trigger the refresh.
Second Edit: To have the Dialog Page tell the Main Page to update that grid:
RaiseBubbleEvent(this, new CommandEventArgs("DataUpdated", "This could be null, or I could be a message to let the user know things are updated"));
Then on your main Page
protected override bool OnBubbleEvent(object sender, EventArgs e)
{
if (e is CommandEventArgs)
{
var args = (CommandEventArgs)e;
//Could use args.CommandArgument here
switch(args.CommandName)
{
case "DataUpdated":
gvMyGrid.DataSource = myData;
gvMyGrid.DataBind();
return true; //Handled the event LIKE A BOSS
}
}
return false; //I didn't handle this event
}