Dropdown List Box PostbackURL?

Posted on 2006-04-19
Last Modified: 2008-01-09
I have a page that has a dropdown listbox that enables users to select which field to sort the display by, using a postback. Problem is that the page goes by many names (i.e. i rewrite the url) so sometimes the page URL is /products/vcr.aspx and sometimes /products/components/speakers.aspx etc. the URL of the actual pages is /products/products.aspx.
When the /products/products.aspx page is displayed a rewritten URL (i.e. /digital-cameras.aspx), the dropdown listbox doesn't postback to /products/products.aspx or /digital-cameras.aspx but to /products.aspx (which doesn't exist) and so returns an error. The ASP button has a PostbackURL property to control where the postback is directed, is there something similar for the dropdown listbox? Any ideas on how to get around this?
Question by:ctudorprice
    LVL 29

    Expert Comment

    by:David H.H.Lee
    I'm not sure how you rewrite url based on your current problem. Do you write your code in Application_BeginRequest routine under web.config? If can, post some working code here, so all of us can see how to help you solve the problem.
    By the way, try to access your root folder start with "~". Seem the url point to wrong folder.

    Author Comment

    hi - code is in application_beginrequest. The problem is not with the url rewriting but with the <form action=...> being set to the rewritten URL and thus any postbacks from my dropdown listbox are being directed to the rewritten url, not the physical page URL.
    I think I may have found a solution adding a javascript to every page override the form's action.... will let you know.

    Author Comment

    Here's what I did to fix this:

    Page.ClientScript.RegisterStartupScript(Me.GetType, "PostBackFix", "<script language=""JavaScript"" type=""text/javascript"" >document.forms[0].action='';</script>   ")

    this ensures that the postback is sent to the actual page, not the rewritten url.

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now