Refreshing a page when action takes place on another page
-
I have 2 pages (Presentations.aspx.cs) and (CustomerSlides.aspx.cs). I have url paths in my database which show different pages on (Presentations.aspx.cs) when clicking in a meny on the same page. These pages will be also shown at the same time on (CustomerSlides.aspx.cs) every time I click in the men in (Presentations.aspx.cs). The url paths in the first Page are saved in an application object (application["fullpath"]) and retrieved in the second page. See my code below. I want the second page to refresh every time I click on a different link in the (Presentations.aspx.cs) menu so that I can see the same url in (CustomerSlides.aspx.cs). How to do that? Maybe the solution is from global.asax. Thanks in advance Here is Presentations.aspx.cs: private void Page_Load(object sender, System.EventArgs e) { if ((Request.Params["SlideID"] != string.Empty) & (Request.Params["SlideID"] != null)) { //Get the SlideID int slideID; slideID = int.Parse(Request.Params["SlideID"]); //Create an instans of PresentationDB PresentationDB url = new PresentationDB(); SqlDataReader dr = url.GetSlide(slideID); dr.Read(); string fullPath; fullPath = dr.GetString(0); //This is needed for the database path info // string overflowPath = "c:\inetpub\wwwroot"; // string exactPath = fullPath.Replace(overflowPath, string.Empty); //Save the fullPath in a Session, this value will be retrieved for use in (CustomerSlides.aspx.cs) Application["fullPath"] = fullPath; //Find the mainIframe control and add a source attribute to it HtmlControl mainIframe = (HtmlControl)this.FindControl("menuForm").FindControl("mainIframe"); mainIframe.Attributes["src"] = fullPath; } else { HtmlControl mainIframe = (HtmlControl)this.FindControl("menuForm").FindControl("mainIframe"); mainIframe.Attributes["src"] = "Main.aspx"; } } Here is CustomerSlides.aspx.cs: public class CustomerSlides : System.Web.UI.Page { protected System.Web.UI.WebControls.Label Message; protected System.Web.UI.HtmlControls.HtmlGenericControl mainIframe; private void Page_Load(object sender, System.Event
-
I have 2 pages (Presentations.aspx.cs) and (CustomerSlides.aspx.cs). I have url paths in my database which show different pages on (Presentations.aspx.cs) when clicking in a meny on the same page. These pages will be also shown at the same time on (CustomerSlides.aspx.cs) every time I click in the men in (Presentations.aspx.cs). The url paths in the first Page are saved in an application object (application["fullpath"]) and retrieved in the second page. See my code below. I want the second page to refresh every time I click on a different link in the (Presentations.aspx.cs) menu so that I can see the same url in (CustomerSlides.aspx.cs). How to do that? Maybe the solution is from global.asax. Thanks in advance Here is Presentations.aspx.cs: private void Page_Load(object sender, System.EventArgs e) { if ((Request.Params["SlideID"] != string.Empty) & (Request.Params["SlideID"] != null)) { //Get the SlideID int slideID; slideID = int.Parse(Request.Params["SlideID"]); //Create an instans of PresentationDB PresentationDB url = new PresentationDB(); SqlDataReader dr = url.GetSlide(slideID); dr.Read(); string fullPath; fullPath = dr.GetString(0); //This is needed for the database path info // string overflowPath = "c:\inetpub\wwwroot"; // string exactPath = fullPath.Replace(overflowPath, string.Empty); //Save the fullPath in a Session, this value will be retrieved for use in (CustomerSlides.aspx.cs) Application["fullPath"] = fullPath; //Find the mainIframe control and add a source attribute to it HtmlControl mainIframe = (HtmlControl)this.FindControl("menuForm").FindControl("mainIframe"); mainIframe.Attributes["src"] = fullPath; } else { HtmlControl mainIframe = (HtmlControl)this.FindControl("menuForm").FindControl("mainIframe"); mainIframe.Attributes["src"] = "Main.aspx"; } } Here is CustomerSlides.aspx.cs: public class CustomerSlides : System.Web.UI.Page { protected System.Web.UI.WebControls.Label Message; protected System.Web.UI.HtmlControls.HtmlGenericControl mainIframe; private void Page_Load(object sender, System.Event
Nope... you need to control the user's browser so this can only be done on the client side. Take a look at this javascript. http://forums.devshed.com/t53270/s.html[^] Torin Blair
'In the immortal words of Socrates - "I drank what?".' -
Nope... you need to control the user's browser so this can only be done on the client side. Take a look at this javascript. http://forums.devshed.com/t53270/s.html[^] Torin Blair
'In the immortal words of Socrates - "I drank what?".'I tried now with client script but it is not working. It does not recognise win2 (which contains the other page, "CustomerSlide.aspx") Which I want to reload by clicking on a link from Presentation.aspx. See my code below. I'm getting this error message: location is null or not an object. Feel free to edit in my code.Thanks. <%@ Page language="c#" Codebehind="Presentations.aspx.cs" AutoEventWireup="false" Inherits="Presentations" %> <%@ Register TagPrefix="LAIKAMENU" TagName="Menu" Src="_Menu.ascx" %> Presentations var win2; function change(href){ win2.location.href = href; } var win2; function change(href){ win2.location.href = href; } function reloadwin2(){ var win2; win2.location.href = "CustomerSlides.aspx"; win2.location.reload(); }
-
I tried now with client script but it is not working. It does not recognise win2 (which contains the other page, "CustomerSlide.aspx") Which I want to reload by clicking on a link from Presentation.aspx. See my code below. I'm getting this error message: location is null or not an object. Feel free to edit in my code.Thanks. <%@ Page language="c#" Codebehind="Presentations.aspx.cs" AutoEventWireup="false" Inherits="Presentations" %> <%@ Register TagPrefix="LAIKAMENU" TagName="Menu" Src="_Menu.ascx" %> Presentations var win2; function change(href){ win2.location.href = href; } var win2; function change(href){ win2.location.href = href; } function reloadwin2(){ var win2; win2.location.href = "CustomerSlides.aspx"; win2.location.reload(); }
It appears that you've defined the variable
win2
several times, both as a global and local variable. This is going to cause inconsistent results, the global instance ofwin2
will be hidden by the local instance for those functions where it is defined. I'd recommend that you alter the javascript, perhapse something like:var win2; function Change(newHref) { win2.location.href = newHref; } function ReloadWin2() { win2.reload(); }
Also, why are you setting the location in thereloadwin2
function? Shouldn't that function just reload the page being displayed [as written above]? Hope that helps. :) --Jesse