Link to home
Start Free TrialLog in
Avatar of ctudorprice
ctudorprice

asked on

Dropdown List Box PostbackURL?

Hi,
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?
Thanks
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

ctudorprice,
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.
eg:
Context.RewritePath("~/product/products.aspx");
Avatar of ctudorprice
ctudorprice

ASKER

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.
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.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial