473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Id is changed on my server control! (_ctl5)

I am sending the values from the servercontrol (HtmlSelect) by the method of
GET and its anoying that ASP.NET changes the Id.

Instead of this: <select id="_ctl5_language"> it should be <select
id="language">.

Any ideas.

Thanks,
Anders
Nov 18 '05 #1
6 1204
Hi,

ASP.NET changes the ID if your control is contained inside a naming
container. It does this to provide guaranteed unique IDs to each and every
control on the Page.

In server-side code the original ID you gave works normally. You get the
generated ID by using ClientID property of the control. However, with
posting it doesn't seem to help. Best you can do is to name the container
explicitly (now it seems that _ctl5 is autogenerated) and then determine the
ID based on that and use that on the receiving Page.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke

"news.microsoft.com" <as**@os.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
I am sending the values from the servercontrol (HtmlSelect) by the method of GET and its anoying that ASP.NET changes the Id.

Instead of this: <select id="_ctl5_language"> it should be <select
id="language">.

Any ideas.

Thanks,
Anders

Nov 18 '05 #2
If you use the control in a repeater, datalist or datagrid control it is
normal to do this otherwise you will have more than one controls with one id

Regards
Martin

"news.microsoft.com" <as**@os.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
I am sending the values from the servercontrol (HtmlSelect) by the method of GET and its anoying that ASP.NET changes the Id.

Instead of this: <select id="_ctl5_language"> it should be <select
id="language">.

Any ideas.

Thanks,
Anders

Nov 18 '05 #3
"news.microsoft.com" <as**@os.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
I am sending the values from the servercontrol (HtmlSelect) by the method of GET and its anoying that ASP.NET changes the Id.

Instead of this: <select id="_ctl5_language"> it should be <select
id="language">.


Why did you want the ID to stay the same? Were you using Request.Form?
Instead, get the value from the control - HtmlSelect.SelectedIndex.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #4
Hi Teemu, thanks for the reply.

I load the control in like this: skin = Page.LoadControl(skinPath);

And as you say if I define the ID it will use that instead of _ctl5.
Isnt there a way to avoid it from attaching itself to all the child
controlds? (Well damnit you already gave me the answer on that)

Best,
Anders
skin = Page.LoadControl(skinPath);
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

ASP.NET changes the ID if your control is contained inside a naming
container. It does this to provide guaranteed unique IDs to each and every
control on the Page.

In server-side code the original ID you gave works normally. You get the
generated ID by using ClientID property of the control. However, with
posting it doesn't seem to help. Best you can do is to name the container
explicitly (now it seems that _ctl5 is autogenerated) and then determine the ID based on that and use that on the receiving Page.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke

"news.microsoft.com" <as**@os.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
I am sending the values from the servercontrol (HtmlSelect) by the
method of
GET and its anoying that ASP.NET changes the Id.

Instead of this: <select id="_ctl5_language"> it should be <select
id="language">.

Any ideas.

Thanks,
Anders


Nov 18 '05 #5
Hi John,

The ID is visible in the URL once a post has been made so I want it to look
nice.

Also in order to avoid the viewstate info I am sending the values back thus
using Request.Form.

"John Saunders" <jo**************@notcoldmail.com> wrote in message
news:ez**************@tk2msftngp13.phx.gbl...
"news.microsoft.com" <as**@os.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
I am sending the values from the servercontrol (HtmlSelect) by the
method of
GET and its anoying that ASP.NET changes the Id.

Instead of this: <select id="_ctl5_language"> it should be <select
id="language">.


Why did you want the ID to stay the same? Were you using Request.Form?
Instead, get the value from the control - HtmlSelect.SelectedIndex.
--
John Saunders
johnwsaundersiii at hotmail

Nov 18 '05 #6
"news.microsoft.com" <as**@os.com> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
Hi John,

The ID is visible in the URL once a post has been made so I want it to look nice.

Also in order to avoid the viewstate info I am sending the values back thus using Request.Form.
Request.Form has nothing to do with avoiding ViewState. I suggest you take a
look at the value of SelectedIndex. You'll find that it has the same value
you're looking for in Request.Form.
--
John Saunders
johnwsaundersiii at hotmail
"John Saunders" <jo**************@notcoldmail.com> wrote in message
news:ez**************@tk2msftngp13.phx.gbl...
"news.microsoft.com" <as**@os.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
I am sending the values from the servercontrol (HtmlSelect) by the

method
of
GET and its anoying that ASP.NET changes the Id.

Instead of this: <select id="_ctl5_language"> it should be <select
id="language">.


Why did you want the ID to stay the same? Were you using Request.Form?
Instead, get the value from the control - HtmlSelect.SelectedIndex.
--
John Saunders
johnwsaundersiii at hotmail


Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brennon Arnold | last post by:
I have a problem that I figured would be relatively common, but have been unable to find any information on it as of yet. I have a page that contains two DropDownList controls, with the second...
1
by: Jaime Stuardo | last post by:
Hi all.... I am programming in ASP.NET 2.0 and VS.NET 2005 Beta 2. I have a MasterPage that provides basic look & feel for my pages. The main form present in the master page has this...
2
by: Brennon Arnold | last post by:
I have a problem that I figured would be relatively common, but have been unable to find any information on it as of yet. I have a page that contains two DropDownList controls, with the second...
31
by: Kathy | last post by:
I would like to get the old and new value for a change made to a text box so that I can store them in a change history table. What is the best way to do this? I am just learning VB 2005; porting...
7
by: WT | last post by:
Hello, It seems that when a control is set into a ContentPlaceHolder in a page using a MasterPage, it's id is change and FindControl(ID) no more works, is it normal, how to override this or...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.