Find the URL of the calling page when both the calling and the caller pages use Ajax's update panel

hi,

I am trying to find the URL of the calling page when both the calling and the caller pages use Ajax's update panel.

I have used Requst.UrlReferrer for this but it returns empty string.

 I have written this piece of code in page load event of Page1 which will be called by Page2 or Page3.

string url = Convert.ToString(Request.UrlReferrer);if ((url.Contains("Page2.aspx")) || (url.Contains("Page3.aspx")))

{

//Perform some operation

}

 I have update panels on Page1 and Page2.

When Page3 calls Page1 it works fine.But when Page2 calls Page1 it will not work.

Please help me out to solve this .

Thanks.

 

0
vki
2/13/2008 11:51:06 AM
asp.net.ajax-discussion 13973 articles. 1 followers. Follow

7 Replies
1048 Views

Similar Articles

[PageSpeed] 36

Hi,

Thank you for your post!

It sound strange, I have tested it, it works fine.

How did you call Page1 from Page2?

Best Regards,


Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
0
Jin
2/19/2008 2:55:12 AM

Thank you for your reply.

I called page1 from page2 using Response.Redirect("Page1.aspx");

Please note that i am using Ajax's update panel an both pages.

 Thank you.

Kind Regards.

0
jjk84
2/21/2008 4:11:17 AM

Would you please create a simple repro and provide me with it?

Thanks


Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
0
Jin
2/21/2008 9:04:42 AM

Thank you for your reply.

Following is my piece of code.

//Page 1.aspx

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<div>

&nbsp;<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<asp:Button ID="btnPage1" runat="server" OnClick="btnPage1_Click" Text="Call Page2" />

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

</body>

</html>

 

//Page1.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class Page1 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

Response.Write(
"Welcome To Page1");

Response.Write("<br>");

string url = Convert.ToString(Request.UrlReferrer);if ((url.Contains("Page2.aspx")) || (url.Contains("Page3.aspx")))

{

Response.Write(url +
" called me");

}

}

protected void btnPage1_Click(object sender, EventArgs e)

{

Response.Redirect(
"Page2.aspx");

}

}

//Page2.aspx

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

<!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>

</head>

<body>

<form id="form1" runat="server">

<div>

&nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<br />

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<asp:Button ID="btnP2" runat="server" OnClick="btnP2_Click" Text="Call Page3" />

&nbsp; &nbsp; &nbsp;<asp:Button ID="btnPage2" runat="server" OnClick="btnPage2_Click"

Text="Call Page1" />

&nbsp;&nbsp;

</ContentTemplate>

</asp:UpdatePanel>

 

</div>

</form>

</body>

</html>

//Page2.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class Page2 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

Response.Write(
"Welcome To Page2");

}

protected void btnPage2_Click(object sender, EventArgs e)

{

Response.Redirect(
"Page1.aspx");

}

protected void btnP2_Click(object sender, EventArgs e)

{

Response.Redirect(
"Page3.aspx");

}

}

//Page3.aspx

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

<!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>

</head>

<body>

<form id="form1" runat="server">

<div>

&nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<br />

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<asp:Button ID="btnPage3" runat="server" Text="Calls Page1" OnClick="btnPage3_Click" />

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

</body>

</html>

//Page3.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class Page3 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

Response.Write(
"Welcome To Page3");

}

protected void btnPage3_Click(object sender, EventArgs e)

{

Response.Redirect(
"Page1.aspx");

}

}

0
jjk84
3/13/2008 5:10:09 AM

Hi,

Thank you for your feedback! 

You cann't use  Response.Write in AsyncPostBack.

Use isinasyncpostback property to check it. http://msdn2.microsoft.com/en-us/library/system.web.ui.scriptmanager.isinasyncpostback.aspx

If you have further questions,let me know!

Best Regards, 


Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
0
Jin
3/13/2008 10:04:02 AM

Thank you for your reply.

I tried using it as below.It did not work.

//Page1.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class Page1 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

 

if (!Page.IsPostBack && ScriptManager1.IsInAsyncPostBack)

{

Response.Write(
"Welcome To Page1");

Response.Write("<br>");

string url = Convert.ToString(Request.UrlReferrer);if ((url.Contains("Page2.aspx")) || (url.Contains("Page3.aspx")))

{

Response.Write(url +
" called me");

}

}

}

protected void btnPage1_Click(object sender, EventArgs e)

{

Response.Redirect(
"Page2.aspx");

}

}

My concern is just to find

if ((url.Contains("Page2.aspx")) || (url.Contains("Page3.aspx")))

and on the basis of this condition perform some operation.

Any suggessions please.

Thak you .

 

0
jjk84
3/15/2008 9:11:53 AM

!Page.IsPostBack && ScriptManager1.IsInAsyncPostBack always return false.


Sincerely,
Jin-Yu Yin
Microsoft Online Community Support
0
Jin
3/17/2008 1:30:12 AM
Reply:

Similar Artilces:

Find the URL of the calling page when ajax's update panel is used
hi,I am trying to find the URL of the calling page when both the calling and the caller pages use Ajax's update panel.I have used Requst.UrlReferrer for this but it returns empty string. I have written this piece of code in page load event of Page1 which will be called by Page2 or Page3.string url = Convert.ToString(Request.UrlReferrer);if ((url.Contains("Page2.aspx")) || (url.Contains("Page3.aspx"))) {//Perform some operation } I have update panels on Page1 and Page2.When Page3 calls Page1 it works fine.But when Page2 calls Page1 it will not work.Please hel...

Master Page's Page Load firing twice on events called from other Page events
I have numerous pages tied to my MasterPage that controls 2 Always visible extenders for User Reminders and a Counter. I would like them to only fire on a Page_Load once, not twice. I have read a million posts about AutoEventWireupset to false, but on all my pages it is set to true and on those pages the events only fire once. The Master page is giving me problems on events firing twice. Any suggestions? here is some code... protected void Page_Load(object sender, EventArgs e) {if (!Page.Master.IsPostBack) {  I call 2 stored procedures here that should only fire once on a Page_Lo...

Using Atlas updatepanel to update a webpart usercontrol content that's hosted in an Ajax page
Hello all, I have an Atlas enabled page which already has a Scriptmanager and some updatepanels doing some AJAX work. In this page I have a section which runs a webpart. There is a usercontrol sitting in this webpart and the content in the usercontrol is updated via a updatepanel using Atlas. I am unable to get the webpart to work as ASP.NET will not allow me to add the usercontrol into the webpart since there is already a Scriptmanager sitting on the main default.aspx page. I am also not able to get the usercontrol to work properly in the webpart as I need to have the scriptmanager s...

ajax .net 2 after ajax call is done how to call JS alert
 helo guys, i'm new herekindly let me know, i've used the folowing but no alertin debug i saw cursor is coming but no alert     Dim strScript As String = "<script language=JavaScript>"        strScript += "alert(""" & StrMessage & """);"        strScript += "</script>"        If (Not Page.ClientScript.IsStartupScriptRegistered("Alertscript")) Then   &nb...

I need to disable the browsers back button because I'm using WFC AJAX web services calls and my entire app is 1 aspx page.
I'm building a shopping cart site that basically has a login page that directs you to a single catalog page that makes client web services calls.  To the end user, it appears as multiple pages, but I'm only hidding and displaying 5 divs catalog, cart, checkout and so on.  If the users hit's the browsers back button, it takes them to the login page, but they may only be trying to navigate back to the div they where currently viewing. I feel like this is going to become more of a problem with the new AJAX stuff coming out, has anyone else run into this or have ...

how to know the calling page from called page.
hi, i need to know how to get the calling page from the called page even there is no post back has been done. Look at the ServerVariables, in particular the Referer i am having the linkbutton in the previous page called page1. while clicking the button the page is redirect to the current page called page2. now i want to know the name or url of the page1. how can i do???? As I already said.... HttpContext.Current.Request.ServerVariables("HTTP_REFERER") Thank You so much... it works very well.......

can v do partial update in page and code also using Ajax update panel?
can v do partial update in page and code also using Ajax update panel? I mean i have 2 user controls in my page. I have applied update panel in 1st user control. After clicking some action button, I want execute the code for first user control only.  But in my case, 2 user controls are getting loaded. But 1st user control only updated in page. This(2nd user control) is unnecessary calling la.  Please read this thread:UpdatePanels inside UserControls ...

Calling other page's button event being in another page
hi, I have a webpage which contains one button to perform certain work. Now I want to call that event being in another page.  Can I do that, Thank you,   surenderkumar : I want to call that event being in another pageWhat event? Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET  Why not factor your event handler code into another class, and call that from both pages?My Blog It is not possible in web applicarion.    I'm ...

how to call one page's page_load event from master page
hi i m using a master page and i simply want to call the page load event of the aspx page(which contains master page)from master page. is it possible? how can i do this? thanks in advance. shweta   ThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path You shouldn't need to do that. Page_Load will be called automatically. The IIS runtime is responsible for calling the Page_Load() event.  I don't think there is a practical way to call a Page load event from the master page.  I can't really thi...

How could a master page control call a content page's function?
Dear all: For example: 1. In master page, place a button named "button1" . 2. Add three content page, ( add some code )3. Run application, in content page 1, click button1, show "this is page1",  in content page2, click button1, show "this is page2", and so on . Besides, these code should be in every content page instead of in master page, because actually action should be very complex, master can't predict everything. Is this possible?  Thanks!  Here's a great tutorial that may get you started: Creating a Common Toolbar in ASP.NET ...

AJAX, Calling a web service inside Master page from its child page
Dear Team  I am using ASP.NET2.0, C#, AJAX.  I am having a Master page that I add inside it a script manager: <form id="form1" runat="server" defaultbutton="btnMaster">    <asp:ScriptManager ID="ScriptManager1" runat="server">        <Services>            <asp:ServiceReference Path="QuoteDeleteRow.asmx"/>        </Services>    </as...

Master Page multiple content page ajax update panel question
I am working on a web site, using quite a bit of the ajax tookit items that is working nicely. I want to not get the full postback flicker in the header/footers of the individual web pages (about 5 pages with ajax tab controls, multiview and other asp controls). I want to be able to move from page to page and not update the header/footers from the master page, just updating 2 content placeholders on each page. I have tried about everything but get full postbacks all the time in the header and footer. I have the script manager in the master page and have tried update panels in the master page...

Trouble calling pages from MSFTs Corporate Template's master page
  Normal 0 MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman";} Well, this is my first attempt at doing anything with ASP.NET and up until now its been pret...

load page in div using ajax --> ajax functionality lost :s
 Hi all,I found some javascript on the net to load a page in a div. Now the problem is that the loading of the page in the div works, but then when I use ajax-functionality in the page loaded in the div, the page just refreshes. Here I found the code: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htmHere is a simular thread (his issue got resolved but mine not. On his site things seem to work just fine :s): http://forums.asp.net/t/1163067.aspx Here is my working demo showing what goes wrong:This is my situation:I have 2 pages: Default and Content.Default loads Content on i...

Web resources about - Find the URL of the calling page when both the calling and the caller pages use Ajax's update panel - asp.net.ajax-discussion

Resources last updated: 1/17/2016 9:47:20 AM