CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 7/2/2007 11:24:26 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 26 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
chrigil
Asp.Net User
How to get Value of a DDL (or any other control) when using nested Mastepage7/2/2007 11:24:26 AM

0/0

Can anyone tell me how to find the value of a control, such as a DropDownList, when using Nested Masterpages? 

If I have a DropDownList

<asp:DropDownList id="myDropDownListID" runat="server"></asp:DropDownList>

in a normal situation, I can retreive the value or selected index by doing myDropDownListID.SelectedIndex or myDropDownList.SelectValue etc.  This works fine.

The problem comes when you have your DropDownList in a Web USer Control and/or a Nested MasterPage. The ASP.Net compiler alters the ID of your DropDownlist in order to make the ID totally unique.  Due to the fact that the compiler cannot guarantee that the programmer won't insert 2 controls into the same page, it prefixes the DDL ID with the control ID. If this is in a Masterpage it will prefix the Masterpage ID/Name.  This means that the control ID will change from myDropDownListID to myWebControlID.myDropDownListID or even myMasterPageID.myWebControlID.myDropDownListID In actual fact the name will change to something more along the lines of ctl00$ctl00$myMasterPageID$myWebControlID$myDropDownListID$ctl09$ctl00.  God only knows why the compiler insists on inserting ctl00 etc.

 Anyway, back to my actual question:

Does anybody know how I can do the equivalent of myDropDownListID.SelectedIndex without doing ctl00$ctl00$myMasterPageID$myWebControlID$myDropDownListID$ctl09$ctl00.SelectedValue which I simply don't believe is the correct way to do it. I've messed around with Me.FindControl("myDropDownListID") with no luck.

Any ideas as this is driving me crazy? I simply don't believe that as son as you start putting controls inside Masterpages or Web Controls you loose the benefits of beign able to do myDropDownListID.SelectedIndex or whatever. At the moment the only way I can get the value is by using the name of the control which doesnt change i.e. Request.Quesrystring("myDDLName").

 

Thanks in advance,

Chris

naturehermit
Asp.Net User
Re: How to get Value of a DDL (or any other control) when using nested Mastepage7/2/2007 11:55:14 AM

0/0

Use DropDownlist.ClientId, however bear in mind dynamic controls or controls added inside data control or duing runtime have to be deduced in certain way as and when they are created during runtime.


Please Mark Post that helped you as answer, also include a summary of what solved the problem as it helps others in similar situations
Ambilykv
Asp.Net User
Re: How to get Value of a DDL (or any other control) when using nested Mastepage7/2/2007 12:01:26 PM

0/0

hi,

u try this way

Master.FindControl("ContentPlaceHolder1").FindControl("DropDownList1")

Hope this wil work 

chrigil
Asp.Net User
Re: How to get Value of a DDL (or any other control) when using nested Mastepage7/2/2007 12:12:13 PM

0/0

Hi, thanks for the speedy response.

DropDownList.ClientId does indeed give me the full ID of the control but I can't use it to find the selected index. I can't do DropDownList.ClientId.SelectedIndex because ClientId is a string. I also can't do FindControl(DropDownList.ClientId).SelectedIndex

How do I take the client id and get the value?

Thanks in advance,

Chris

naturehermit
Asp.Net User
Re: How to get Value of a DDL (or any other control) when using nested Mastepage7/2/2007 12:52:23 PM

0/0

By casting it...Drop your code here and can advise..


Please Mark Post that helped you as answer, also include a summary of what solved the problem as it helps others in similar situations
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:





Search This Site:










accessing custom control properties from another window

the child portal adminstrator can not see the admin tab

building an asp intranet from wrox book

forms authentication and ticket persistence

service unavailable when changing from asp.net 1.1 to 2.0 in iis

dnn 1.0.10d upgrade question

3.0.10 issue: friendly url enhancement missing

login problems with dnn and ie?

test if user is in a group

don´t know how to record a form inside of database

vs 2005 error list -- list all asp.net files?

tabs

debug issue ?

text / html module error

language editor -edit

which feature is there in this breadcrumb

adding new functionality to core modules

dnn 3.0.13: preview mode stuck on: cannot toggle preview mode

problem in path on master page

skin upload error

error adding object to linq to sql class

dnn 2.0.4 - skin installer should not touch special links

imc example

appeal to module creator

migrating from coldfusion to .net

help - status of css positioning in dnn 2.1.2

select an item from a menu at runtime?

problem with forms authentication user "crossover"

dnn skin problem

how do you develop skins?

 
All Times Are GMT