Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to append DropDownList value to button's PostBackUrl?

Reply
Thread Tools

How to append DropDownList value to button's PostBackUrl?

 
 
rob
Guest
Posts: n/a
 
      03-20-2008
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


 
Reply With Quote
 
 
 
 
David Wier
Guest
Posts: n/a
 
      03-20-2008
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" <> wrote in message
news:%...
> 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
>



 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      03-20-2008
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/ar...on-change.aspx

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

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



"rob" <> wrote in message
news:%...
> 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
>



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      03-20-2008
Forgot to say, it should also work for DropDownList just as well as for
ListBox.


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


"Teemu Keiski" <> wrote in message
news:...
> 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/ar...on-change.aspx
>
> I demonstrate how to use PostBackUrl type of stuff (=cross-page postback)
> so that the value is accessible via PreviousPage
>
> --
> Teemu Keiski
> AspInsider, ASP.NET MVP
> http://blogs.aspadvice.com/joteke
> http://teemukeiski.net
>
>
>
> "rob" <> wrote in message
> news:%...
>> 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
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Append a new value to dict Pat Python 19 11-17-2010 11:02 PM
Append value on the command line to a predefined macro in the makefile micropentium C Programming 8 01-28-2010 06:48 PM
append .cvs behind an array value Martin Sharon Ruby 4 04-27-2009 05:08 AM
the address of list.append and list.append.__doc__ HYRY Python 10 09-26-2007 09:41 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57