Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

How to append DropDownList value to button's PostBackUrl?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rob - 20 Mar 2008 17:44 GMT
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
David Wier - 20 Mar 2008 18:29 GMT
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

> Hi,
>
[quoted text clipped - 7 lines]
> Thanks,
> Rob
Teemu Keiski - 20 Mar 2008 21:01 GMT
Hi,

this does not reply 100% exactly what you asked for but in my post

ASP.NET: trigger cross-page postback on ListBox selection change
http://aspadvice.com/blogs/joteke/archive/2007/11/11/ASP.NET_3A00_-trigger-cross
_2D00_page-postback-on-ListBox-selection-change.aspx


I demonstrate how to use PostBackUrl type of stuff (=cross-page postback)
so that the value is accessible via PreviousPage

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

> Hi,
>
[quoted text clipped - 7 lines]
> Thanks,
> Rob
Teemu Keiski - 20 Mar 2008 21:03 GMT
Forgot to say, it should also work for DropDownList just as well as for
ListBox.

Signature

Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

> Hi,
>
[quoted text clipped - 17 lines]
>> Thanks,
>> Rob

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.