Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Id is changed on my server control! (_ctl5)

Reply
Thread Tools

Id is changed on my server control! (_ctl5)

 
 
news.microsoft.com
Guest
Posts: n/a
 
      07-15-2004
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


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-15-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Martin Marinov
Guest
Posts: n/a
 
      07-15-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      07-15-2004
"news.microsoft.com" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
news.microsoft.com
Guest
Posts: n/a
 
      07-15-2004
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
news.microsoft.com
Guest
Posts: n/a
 
      07-15-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "news.microsoft.com" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      07-15-2004
"news.microsoft.com" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > "news.microsoft.com" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> >
> >

>
>



 
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
changed state to up changed state to down FastEthernet LINEPROTO-5-UPDOWN surrealarmada@gmail.com Cisco 3 03-07-2007 06:06 PM
scroll position is changed when style is changed? mxbrunet Javascript 1 11-03-2006 03:40 AM
xmlDocument.Save "&#10;" getting changed changed to "&amp;#10" st@jpa.co.jp ASP .Net 1 10-11-2005 01:30 PM
server side code access the text of <asp:label> changed by client-side javascript code? nick ASP .Net 3 12-15-2004 06:26 PM
ListBox items changed client-side are not available server-side Valerian John ASP .Net 6 05-17-2004 06:45 PM



Advertisments