Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accessing value of dropdown in user control from main page

Reply
Thread Tools

Accessing value of dropdown in user control from main page

 
 
=?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=
Guest
Posts: n/a
 
      12-21-2005
I have a user control, dropdown.ascx

Inside dropdown.ascx, I have a dropdownlist control.

From my page.aspx, I need to be able to access the dropdown's value.

By setting it to auto-post back, I am able to grab this value using
Request.Form["Control:ddlValues"]. This worked well until I realized that I
needed the initial value in some cases. How do I access this value from the
page.aspx file?

Thank you very much.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      12-22-2005
Brenden,

1- Define an event for your control that you raise whenever the
dropdownlist SelectedIndexChanged is handled,
2- Define a class that holds event data (which you can customize to hold
both the old and the new values of the dropdownlist)
3- Define an event delegate so that your page.aspx can subscribe to it and
collect the old and new values from your customized eventargs.

For a demo on this strategy:
http://www.societopia.net/Samples/Da...olsEvents.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Brenden Bixler" wrote:

> I have a user control, dropdown.ascx
>
> Inside dropdown.ascx, I have a dropdownlist control.
>
> From my page.aspx, I need to be able to access the dropdown's value.
>
> By setting it to auto-post back, I am able to grab this value using
> Request.Form["Control:ddlValues"]. This worked well until I realized that I
> needed the initial value in some cases. How do I access this value from the
> page.aspx file?
>
> Thank you very much.

 
Reply With Quote
 
 
 
 
bhawin13
Guest
Posts: n/a
 
      12-22-2005
Hello Brenden Bixler

Simplest thing is to declare your list box public. So you can access it
from your page.
If you will do this you dont need to write any extra wrapper methods.

Correct me If I am wrong.
B

 
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
Accessing USER CONTROL which is inside Masterpagethrough Another USER Control inside normal page. Kiran More ASP .Net Web Controls 2 11-14-2006 12:58 PM
accessing the web user control's control from a web page and set a value from another web page Reny J Joseph Thuthikattu ASP .Net 1 12-30-2004 12:21 PM
Change main window href from IE search panel, after user has left my main page? Robert Oschler Javascript 1 10-12-2004 08:34 PM
How can u connect to 1 of several dbs based on selection user makes when accessing main page hourman ASP General 2 07-21-2003 06:32 PM



Advertisments