Re: How to append DropDownList value to button's PostBackUrl?
- From: "David Wier" <dw@xxxxxx>
- Date: Thu, 20 Mar 2008 12:29:44 -0500
The problem with setting the PostbackURL when you click the button, is that
postback is already beginning.
What you'd probably want to do is set up a variable for the selected item,
with a page scope
Then, when the DDL is changed (using the OnSelectedIndexChanged event),
assign the selected item to the variable - and THEN, set the Postback url,
using the variable (PostBackUrl="somepage.aspx?param=" & myVariable)
Then, when you click the button, it should go there - the problem would then
be whether or not something is actually selected, so you would probably need
to do validation
Or you could just use a response.redirect statement
(response.redirect(="somepage.aspx?param=" & myVariable) within the button's
click event handler
David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
"rob" <r@xxxxx> wrote in message
news:%238gutmqiIHA.5968@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I have a button whose PostBackUrl should include a value from a
dropdownlist on the same page. Should I do that in the button's on click
event? What I'd like to end up with is a post back url that looks like
the following:
PostBackUrl=somepage.aspx?param=<value> where <value> comes from the
currently selected item in the list.
Thanks,
Rob
.
- References:
- Prev by Date: Consuming Web Service on Shared Hosting Platform
- Next by Date: CompositeControl Design Time Error (Could not add List<> property to the collection)
- Previous by thread: How to append DropDownList value to button's PostBackUrl?
- Next by thread: Re: How to append DropDownList value to button's PostBackUrl?
- Index(es):