• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 554
  • Last Modified:

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
0
ctudorprice
Asked:
ctudorprice
  • 2
1 Solution
 
David H.H.LeeCommented:
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");
0
 
ctudorpriceAuthor Commented:
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.
0
 
ctudorpriceAuthor Commented:
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.
0
 
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now