Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prefix on server controls inside a user control

Status
Not open for further replies.

icrf

Programmer
Dec 4, 2001
1,300
US
I have a web user control that I'm including in a page. I have one htmlselect control that's runat=server so it can get populated from the database. Now, this page is not in a runat=server form and does not post, viewstate is disabled. Instead, it's a simple GET form and the field goes up into the query string where the page can be easily bookmarked.

My problem is, since the htmlselect is running at the server in a user control, ASP.NET futzes with the id's, adding a _ctl3_ prefix. I realize it does this to prevent name conflicts, such as including two copies of the user control on a given page. I append the query string to this page from other places as well that will not know the control's clientid, so that is not an option. Changing the control's ID just changes what's after the prefix.

Is there something I can set so the clientid is something I specify? I want "Filter" not "_ctl3_Filter". Perhaps I'm just used to other languages that always give the developer enough rope to hang himself. Any way to disable this prefix safety feature on a specific page/control/user control?

My other option is to generate the control with a repeater, but this is a less clean design, albeit fully functional.

Thanks.

________________________________________
Andrew

I work for a gift card company!
 
Can't you use the FindControl method to find the control you want (i.e. so that it doesn't matter what id has been assigned to the control?)

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
It's not a question of finding the control so much as keeping a consistent way of setting the data. For example, I have three user controls, a menu, an index, and a catalog. Initially, the menu and index is displayed. From the menu, the catalog can be loaded in place of the index, possibly a specific part of the catalog. From the catalog or the menu, that part can be changed. The menu is generating url's with query string data, but it doesn't know the client id of something in the catalog, as it's decoupled and may not even be there (ie, the index).

I could probably try to read the id and the clientid from the request to see which one is set and go on based on that.

Am I making sense? I feel like I'm fumbling with words more than usual this morning.

________________________________________
Andrew

I work for a gift card company!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top