Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ken Thai 10 posts 30 karma points
    Apr 11, 2011 @ 04:30
    Ken Thai
    0

    Cross page postback

    Hi,

    I have two page that make use of macro create from 2 different C# user control (Let say Page A and B).

    What I want to achieve is for user to click on a LinkButton on Page A and cross-page posting to Page B (using PostbackURL property of LinkButton). Is this possible with Umbraco?

    I manage to create the LinkButton and logic work fine locally on my computer. But when i post the control onto server, i got the YSOD (Yellow Screen Of Death) saying

    [HttpException (0x80004005): The file '/PageA' does not exist.]

    Any help would be much appreciate

  • Daniel Bardi 927 posts 2562 karma points
    Apr 11, 2011 @ 07:09
    Daniel Bardi
    0

    Are these physical pages or umbraco nodes?

  • Ken Thai 10 posts 30 karma points
    Apr 11, 2011 @ 07:32
    Ken Thai
    0

    Hi Daniel,

    Those page are .NET user control on umbraco pages/nodes.

    Regards,

    Ken

  • Daniel Bardi 927 posts 2562 karma points
    Apr 11, 2011 @ 07:58
    Daniel Bardi
    0

    Probably been checked... let me know.

    Can you browse to the node/page directly?

    Have you tried adding .aspx to the url.

    Do you have directoryUrls enabled?

  • Ken Thai 10 posts 30 karma points
    Apr 11, 2011 @ 08:26
    Ken Thai
    0

    I can browse to node/page directly.

    Haven't try adding .aspx to url <-- Correction, just try adding .aspx and the getting the same error message. But this time, insteand of /PageA, it is /PageA.aspx couldn't be found

    DirectoryUrls is turn on

     

  • Daniel Bardi 927 posts 2562 karma points
    Apr 11, 2011 @ 08:59
    Daniel Bardi
    0

    What does your code for the redirect look like?  Please paste.

    BTW.. useDirectoryUrls is set in web.config appsettings.  (false by default)

  • Ken Thai 10 posts 30 karma points
    Apr 12, 2011 @ 01:35
    Ken Thai
    0

    It is a very simple redirect code

    On PageA is just a LinkButton with a PostBackUrl point to PageB

    <asp:LinkButton ID="linkbutton1" runat="server" PostBackUrl="/PageB" />

    On PageB, the following code in Page_Load event

    if (null != Page.PreviousPage)
    {
    if (true == Page.PreviousPage.IsCrossPagePostBack)
    {
    LinkButton lb = (LinkButton)Page.PreviousPage.FindControls("linkbutton1");
    if (null != lb) {
    this.Label.Text = lb.Text;
    }
    }
    }

    Locally on my computer, this code work flawlessly. But when I port it onto the server, Umbraco send me a YSOD right at the first if statement. This doesn't make any sense to me and I really want to find out why is that the case. I'm running Umbraco 4.5.2 (if that mean anything at all).

    Surely there are other way of achieving my goal (Session, QueryString, Response.Redirect....etc), and I had tried some of them (they work). However, I do not wish to back down from this little problem until I fully understand what causing the YSOD (to me this is part of the learning process).

    BTW, useDirectoryUrls is set to true in my web.config

  • Ken Thai 10 posts 30 karma points
    Apr 12, 2011 @ 02:11
    Ken Thai
    0

    I have a colleague of mine to look at the code. He told me to put in one line of debug code (which i should have done ages ago)

    Response.Write("Page.PreviousPage : \"" + Page.PreviousPage + "\"<br />");

    This line throw me the exact same error as the above code. Does this mean it is an Umbraco bug?

  • Daniel Bardi 927 posts 2562 karma points
    Apr 12, 2011 @ 03:19
    Daniel Bardi
    0

    Change PostBackUrl to the "/PageB/" .. (note the trailing slash)

    If that doesn't help, then try "/PageB.aspx"

    The urls are rewritten to exclude the the .aspx when directoryUrls is set to true... I have a feeling this might not fix things, but I need to know.

    Thanks.

  • Daniel Bardi 927 posts 2562 karma points
    Apr 12, 2011 @ 03:48
    Daniel Bardi
    0

    I entered the following directly into a template on my site and it worked fine.

    Try this directly in your template where the macro is to see if it works.. this way can limit to issue to the macro or somewhere else.

    <asp:LinkButton id="testbutton" PostBackUrl="/" Text="Test PostBack" runat="server"></asp:LinkButton>
  • Ken Thai 10 posts 30 karma points
    Apr 12, 2011 @ 05:36
    Ken Thai
    0

    Hi Daniel,

    I just try what you suggest. It work as we expect it to. I don't think I'm having any problem with the redirection on my site. What trouble me at the moment is the fact that Umbraco doesn't like me use Page.PreviousPage. It just keep on throwing me a YSOD with message say /PageA do not found.

    Does the code I provide above work on your site?

    Thanks

    Ken

  • Daniel Bardi 927 posts 2562 karma points
    Apr 12, 2011 @ 08:50
    Daniel Bardi
    0

    I tried your code and got the same error.

    The problem is with url rewriting and the lack of physical pages.

    Page.PreviousPage is looking for a physical file (i.e. PageA.aspx) and since Umbraco doesn't have physical files and is using url rewriting, you are getting this error.

    I'd recommend using a MultiView control instead since pages are dynamic

     

Please Sign in or register to post replies

Write your reply to:

Draft